1 /* $NetBSD: duplex_pipe.c,v 1.1.1.1 2009/06/23 10:08:59 tron Exp $ */ 2 3 /*++ 4 /* NAME 5 /* duplex_pipe 3 6 /* SUMMARY 7 /* local IPD 8 /* SYNOPSIS 9 /* #include <iostuff.h> 10 /* 11 /* int duplex_pipe(fds) 12 /* int *fds; 13 /* DESCRIPTION 14 /* duplex_pipe() uses whatever local primitive it takes 15 /* to get a two-way I/O channel. 16 /* DIAGNOSTICS 17 /* A null result means success. In case of error, the result 18 /* is -1 and errno is set to the appropriate number. 19 /* LICENSE 20 /* .ad 21 /* .fi 22 /* The Secure Mailer license must be distributed with this software. 23 /* AUTHOR(S) 24 /* Wietse Venema 25 /* IBM T.J. Watson Research 26 /* P.O. Box 704 27 /* Yorktown Heights, NY 10598, USA 28 /*--*/ 29 30 /* System libraries */ 31 32 #include <sys_defs.h> 33 #include <sys/socket.h> 34 #include <unistd.h> 35 36 /* Utility library. */ 37 38 #include "iostuff.h" 39 #include "sane_socketpair.h" 40 41 /* duplex_pipe - give me a duplex pipe or bust */ 42 43 int duplex_pipe(int *fds) 44 { 45 #ifdef HAS_DUPLEX_PIPE 46 return (pipe(fds)); 47 #else 48 return (sane_socketpair(AF_UNIX, SOCK_STREAM, 0, fds)); 49 #endif 50 } 51 52