This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
2008-12-17 Thomas Schwinge <tschwinge@gnu.org> * sysdeps/mach/hurd/pipe2.c: New file, copy from pipe.c. Evolve it to implement __pipe2. * sysdeps/mach/hurd/pipe.c (__pipe): Reimplement using __pipe2. Recipe: Copy sysdeps/mach/hurd/pipe.c to sysdeps/mach/hurd/pipe2.c. Evolve the latter one to implement __pipe2: --- sysdeps/mach/hurd/pipe.c.O 2008-12-17 00:56:21.000000000 +0100 +++ sysdeps/mach/hurd/pipe2.c 2008-12-17 00:59:45.000000000 +0100 @@ -25,27 +25,32 @@ Actually the channel is two-way on the Hurd. If successful, two file descriptors are stored in FDS; bytes written on FDS[1] can be read from FDS[0]. + Apply FLAGS to the new file descriptors. Returns 0 if successful, -1 if not. */ int -__pipe (int fds[2]) +__pipe2 (int fds[2], int flags) { int save_errno = errno; int result; + if (flags & ~(O_CLOEXEC | O_NONBLOCK)) + return __hurd_fail (EINVAL); + + flags = o_to_sock_flags (flags); + /* The magic S_IFIFO protocol tells the pflocal server to create sockets which report themselves as FIFOs, as POSIX requires for pipes. */ - result = __socketpair (PF_LOCAL, SOCK_STREAM, S_IFIFO, fds); + result = __socketpair (PF_LOCAL, SOCK_STREAM | flags, S_IFIFO, fds); if (result == -1 && errno == EPROTONOSUPPORT) { /* We contacted an "old" pflocal server that doesn't support the magic S_IFIFO protocol. FIXME: Remove this junk somewhere in the future. */ __set_errno (save_errno); - return __socketpair (PF_LOCAL, SOCK_STREAM, 0, fds); + return __socketpair (PF_LOCAL, SOCK_STREAM | flags, 0, fds); } return result; } -libc_hidden_def (__pipe) -weak_alias (__pipe, pipe) +weak_alias (__pipe2, pipe2) Perhaps now the time has come to remove the FIXME ``junk''? Reimplement __pipe using __pipe2: diff --git a/sysdeps/mach/hurd/pipe.c b/sysdeps/mach/hurd/pipe.c index 7a5d78c..3dc4c3b 100644 --- a/sysdeps/mach/hurd/pipe.c +++ b/sysdeps/mach/hurd/pipe.c @@ -16,9 +16,6 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <errno.h> -#include <sys/socket.h> -#include <sys/stat.h> #include <unistd.h> /* Create a one-way communication channel (pipe). @@ -29,23 +26,7 @@ int __pipe (int fds[2]) { - int save_errno = errno; - int result; - - /* The magic S_IFIFO protocol tells the pflocal server to create - sockets which report themselves as FIFOs, as POSIX requires for - pipes. */ - result = __socketpair (PF_LOCAL, SOCK_STREAM, S_IFIFO, fds); - if (result == -1 && errno == EPROTONOSUPPORT) - { - /* We contacted an "old" pflocal server that doesn't support the - magic S_IFIFO protocol. - FIXME: Remove this junk somewhere in the future. */ - __set_errno (save_errno); - return __socketpair (PF_LOCAL, SOCK_STREAM, 0, fds); - } - - return result; + return __pipe2 (fds, 0); } libc_hidden_def (__pipe) weak_alias (__pipe, pipe)
Attachment:
signature.asc
Description: Digital signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |