Parent waits for previous child process on linux shell

view story

http://stackoverflow.com – I have a program that forks a process, and determine if child process should run in foreground and background. I call the signal function to handle the child signal before forking, to make sure dead child process will not turn into zombies. So far my program works fine, it creates a child process and runs it on background whenever user input commands with '&', and runs it on foreground whenever user input commands without '&'. However, I found a really interesting behaviour. Suppposed I called this sequence of operations: sleep 5 & ls the first command will work fine, parent (HowTos)