Revision 70e72ce4 oslib-posix.c

b/oslib-posix.c
87 87
    f = fcntl(fd, F_GETFD);
88 88
    fcntl(fd, F_SETFD, f | FD_CLOEXEC);
89 89
}
90

  
91
/*
92
 * Creates a pipe with FD_CLOEXEC set on both file descriptors
93
 */
94
int qemu_pipe(int pipefd[2])
95
{
96
    int ret;
97

  
98
#ifdef CONFIG_PIPE2
99
    ret = pipe2(pipefd, O_CLOEXEC);
100
    if (ret != -1 || errno != ENOSYS) {
101
        return ret;
102
    }
103
#endif
104
    ret = pipe(pipefd);
105
    if (ret == 0) {
106
        qemu_set_cloexec(pipefd[0]);
107
        qemu_set_cloexec(pipefd[1]);
108
    }
109

  
110
    return ret;
111
}

Also available in: Unified diff