Programming and posix - April 2002

April 3, 2002
Solution Symposium
Page 50
hp e3000
programming
and posix
interprocess communication - pipes
Pipes are easy to demonstrate in the shell:
shell/iX> who am i
STEVE,CGI.APACHE@SYSTEMNAME ldev5 TUE 1:04P
shell/iX> who am I | cut -f1 -d' '
STEVE,CGI.APACHE@SYSTEMNAME
int pipe(int filedes[2]);
creates two file descriptors for pipe endpoints
filedes[0] for reading, filedes[1] for writing
pipe()/fork()/dup2()/exec() to do stdout|stdin
piping between two processes
popen()/pclose()
spawns shell pipe to execute a command
BEWARE of shell metacharacter security holes!!!