1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "sandbox/linux/syscall_broker/broker_channel.h"
7 #include <sys/socket.h>
10 #include "base/logging.h"
14 namespace syscall_broker
{
17 void BrokerChannel::CreatePair(EndPoint
* reader
, EndPoint
* writer
) {
21 // Use SOCK_SEQPACKET, to preserve message boundaries but we also want to be
22 // notified (recvmsg should return and not block) when the connection has
23 // been broken which could mean that the other end has been closed.
24 PCHECK(0 == socketpair(AF_UNIX
, SOCK_SEQPACKET
, 0, socket_pair
));
26 reader
->reset(socket_pair
[0]);
27 PCHECK(0 == shutdown(reader
->get(), SHUT_WR
));
29 writer
->reset(socket_pair
[1]);
30 PCHECK(0 == shutdown(writer
->get(), SHUT_RD
));
33 } // namespace syscall_broker
35 } // namespace sandbox