new version of popen(3)
Douglas B. Jones
douglas at dcc1.UUCP
Sat Apr 5 11:04:41 AEST 1986
Hi,
In the routine popen(3), a program can open either a read pipe
or a write pipe to a sub-process (usually a program, like more).
Does any one have a similar routine that will allow a person to
have a read/write pipe to a sub-process. The routine might have
the following format:
FILE *wfp, /* stdin to child */
*rfp, /* stdout from child */
*refp; /* stderr from child */
int p,
popen2();
void pclose2();
if ((p = popen2("program",wfp,rfp,refp)) < 0) {
fprintf(stderr,"Can't open pipe to program\n");
exit(1);
}
At this point :
p : index so that pclose2() would know which child to close
wfp : how I write to the childs' stdin,
rfp : the stdout from the child to me,
rwfp: the stderr from the chid to me.
The pclose2() routine would be called:
(void)pclose2(p); /* p being the return from popen2() */
This would be a very helpful program. I imagine it would have
to deal with sockets(). What would be really nice, is if two version
of this popen2() could be written. One to allow the calling program
to work with a child process on the local system, and secondly to
allow it (the calling program) to work with a child process on
another system (in the local network).
Maybe : popen2() for local (with pclose2()) and npopen2() for
remote (withe npclose2()). Npopen2() might have a calling format
like :
/* other vars. stated above */
char *network = "dcc2"; /* name of our other system */
int npopen2();
void npclose2();
if ((p = npopen2("program",wfp,rfp,refp,network)) < 0) {
fprintf(stderr,"Can't open net pipe to program\n");
exit(1);
}
/* do what ever, ie: write UNIX documentation or crash the system */
(void)npclose2(p);
Thanks in advance,
Douglas
p.s.: Apart from sending this to net.wanted.sources, I am also sending
this to net.unix and net.unix-wizards to reach a larger group of
people. Response might best go to net.sources. I will be happy
to handle responses directly and then post them to net.sources.
--
----------------------------------------------------------------------
Douglas Jones
TSG, DeKalb College
douglas at dcc1
gatech!dcc1!douglas { calls us each hour }
akgua!dcc1!douglas { calls us about twice a day }
akgua!gatech!dcc1!douglas { akgua and gatech communicate a lot }
----------------------------------------------------------------------
More information about the Comp.unix.wizards
mailing list