Reputation: 33
Basically, I am learning pipe and dup system calls.
I want to take a command-name (like ls,cd,mkdir etc) as input from the parent process and pass it on to the child process using pipe, the child process should open up a new xterm window and show the man page of the command recorded in the pipe in this new xterm window.
The problem is that exec changes the whole process image of the child, so any code written after is simply ignored (if exec was successful).So if I exec the child to "/bin/xterm", then any exec calls in the child block are removed, as the process image changed to xterm.
So how do I call /bin/man?
Upvotes: 1
Views: 1517
Reputation: 8142
There is nothing stopping you calling fork
again - a process can have any number of children, grandchildren etc...
In this particular instance you need the child to fork
and create grandchildren that exec
"/bin/xterm" with your man command. And also handle clean up of them as they finish.
Upvotes: 1