mirror of https://github.com/omar-polo/gmid.git
work around missing SOCK_NONBLOCK/CLOEXEC on macos
This commit is contained in:
parent
94893746ae
commit
1b9031f1fc
16
proc.c
16
proc.c
|
@ -238,10 +238,16 @@ proc_init(struct privsep *ps, struct privsep_proc *procs, unsigned int nproc,
|
|||
pa = &ps->ps_pipes[PROC_PARENT][0];
|
||||
pb = &ps->ps_pipes[dst][proc];
|
||||
if (socketpair(AF_UNIX,
|
||||
SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC,
|
||||
SOCK_STREAM,
|
||||
PF_UNSPEC, fds) == -1)
|
||||
fatal("%s: socketpair", __func__);
|
||||
|
||||
mark_nonblock(fds[0]);
|
||||
mark_nonblock(fds[1]);
|
||||
if (fcntl(fds[0], F_SETFD, FD_CLOEXEC) == -1 ||
|
||||
fcntl(fds[1], F_SETFD, FD_CLOEXEC) == -1)
|
||||
fatal("%s: fcntl F_SETFD", __func__);
|
||||
|
||||
pa->pp_pipes[dst][proc] = fds[0];
|
||||
pb->pp_pipes[PROC_PARENT][0] = fds[1];
|
||||
}
|
||||
|
@ -432,10 +438,16 @@ proc_open(struct privsep *ps, int src, int dst)
|
|||
pa = &ps->ps_pipes[src][i];
|
||||
pb = &ps->ps_pipes[dst][j];
|
||||
if (socketpair(AF_UNIX,
|
||||
SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC,
|
||||
SOCK_STREAM,
|
||||
PF_UNSPEC, fds) == -1)
|
||||
fatal("%s: socketpair", __func__);
|
||||
|
||||
mark_nonblock(fds[0]);
|
||||
mark_nonblock(fds[1]);
|
||||
if (fcntl(fds[0], F_SETFD, FD_CLOEXEC) == -1 ||
|
||||
fcntl(fds[1], F_SETFD, FD_CLOEXEC) == -1)
|
||||
fatal("%s: fcntl F_SETFD", __func__);
|
||||
|
||||
pa->pp_pipes[dst][j] = fds[0];
|
||||
pb->pp_pipes[src][i] = fds[1];
|
||||
|
||||
|
|
Loading…
Reference in New Issue