Why do you have spawn_jobs 1,, spawn_jobs 2, and spawn_jobs 3, instead of three functions? It makes it hard to read your code and therefore hard to debug your code.
Comment on Re: rsh <defunct> processes appear when using fork and system calls
For the sake of generality. In the full code (not shown) I have 4 different types of commands I need to spawn. If I didn't have the forking as a subroutine I would have to repeat most of the subroutine code 4 different times, making the code longer, and more difficult to modify (eg if I needed to change code in one of the forking sections I probably would need to change it in the 3 others).