blob: 288437ddbd35e726e9ef671ea6fe500faf53cfd7 [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sandbox/linux/syscall_broker/broker_channel.h"
#include <sys/socket.h>
#include <sys/types.h>
#include "base/check.h"
namespace sandbox {
namespace syscall_broker {
// static
void BrokerChannel::CreatePair(EndPoint* reader, EndPoint* writer) {
int socket_pair[2];
// Use SOCK_SEQPACKET, to preserve message boundaries but we also want to be
// notified (recvmsg should return and not block) when the connection has
// been broken which could mean that the other end has been closed.
PCHECK(0 == socketpair(AF_UNIX, SOCK_SEQPACKET, 0, socket_pair));
PCHECK(0 == shutdown(reader->get(), SHUT_WR));
PCHECK(0 == shutdown(writer->get(), SHUT_RD));
} // namespace syscall_broker
} // namespace sandbox