* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
static char *sccsid
= "@(#)popen.c 5.2 (Berkeley) 6/21/85";
#define tst(a,b) (*mode == 'r'? (b) : (a))
static int popen_pid
[20];
register myside
, hisside
, pid
;
myside
= tst(p
[WTR
], p
[RDR
]);
hisside
= tst(p
[RDR
], p
[WTR
]);
if((pid
= vfork()) == 0) {
/* myside and hisside reverse roles in child */
dup2(hisside
, tst(0, 1));
execl("/bin/csh", "sh", "-c", cmd
, 0);
return(fdopen(myside
, mode
));
omask
= sigblock(sigmask(SIGINT
)|sigmask(SIGQUIT
)|sigmask(SIGHUP
));
while((r
= wait(&status
)) != popen_pid
[f
] && r
!= -1 && errno
!= EINTR
)