Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- the parent process does not wait correctly. You can try this for example
- with a "sleep 5" in the commands. It should wait 5 seconds.
- The problem is, that you start i processes, but you wait only for i-1.
- So the parent does not wait for the last child.
- You can change the value that you pass to i, are you can also get rid of
- this length parameter.
- Instead of counting the children and using a for loop in the wait
- function, you could use a while loop, that calls wait as long as it
- returns not -1. The function wait always waits until any child is closed
- and returns the PID of a child. If there is no child process to wait
- for, it directly returns -1.
- Another thing is, that it would be better to only skip a command with
- too many parameters, instead of calling exit and stopping the complete
- program.
- Andreas
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement