Should check return of pipe notequ 0 is fail.
Use dup2 its better than dup, dont need the close.
dup2( Pipe[1],STDOUT_FILENO ) );
dup2( Pipe[0], STDIN_FILENO ) );
(one in each task)
Why does the parent wait?
Get rid of Wait.
jp does not exit.
Main should be:
int main ( int argc, char *argv[] )
at it returns (via exit)
P.S. you program does not exist once the to commands have run. You could produce to children to do the work.
P.S its K&R style not ANSI style for function arguments.
Main Topics
Browse All Topics





by: MFCRichPosted on 2001-12-05 at 11:28:42ID: 6667961
First, you dont have the NULL pointer at the end of cmd2.
Second, the function jp never returns (no return statement)