When you use waitpid, the first parm is the process id or -1 (if you just want to kill time). For the second parm: you can specify it as 0, then the call is locked; or as 1, and the call is not blocked.
I tested that, if you give an odd number for the second parm, the call does not block; but it blocks on even number. I realized that it's a bit map, and the last bit specifies whether the call is blocked.