daily pastebin goal


a guest Aug 12th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. the parent process does not wait correctly. You can try this for example
  2. with a "sleep 5" in the commands. It should wait 5 seconds.
  3. The problem is, that you start i processes, but you wait only for i-1.
  4. So the parent does not wait for the last child.
  6. You can change the value that you pass to i, are you can also get rid of
  7. this length parameter.
  8. Instead of counting the children and using a for loop in the wait
  9. function, you could use a while loop, that calls wait as long as it
  10. returns not -1. The function wait always waits until any child is closed
  11. and returns the PID of a child. If there is no child process to wait
  12. for, it directly returns -1.
  15. Another thing is, that it would be better to only skip a command with
  16. too many parameters, instead of calling exit and stopping the complete
  17. program.
  20. Andreas
RAW Paste Data