Skip to content
Advertisement

Tag: waitpid

waitpid() function returns ERROR (-1), why?

I’m writing a Linux shell-like program in C. Among others, I’m implementing two built-in commands: jobs, history. In jobs, I print the list of currently working commands (in the background). In history I print the list of all commands history until now, specifying for each command if it’s RUNNING or DONE. To implement the two, my idea was to have

Linux, waitpid, WNOHANG, child process, zombie

I running my program as daemon. Father process only wait for child process, when it is dead unexpected, fork and wait again. But when child process being killed with -9 signal, the child process goes to zombie process. waitpid should return the pid of child process immediately! But waitpid got the pid number after about 90 seconds, Here is the

Advertisement