Question

I coded a basic shell in C for executing basic commands like ls , pwd , ...
I have a feature that can make a process run in the background instead of waiting until its done for example : ls & instead of ls (I have a list that contains the processes that run in the background now)
The whole thing is that I want to know when a process is done or not , so I can remove it from the list .
thanks

Was it helpful?

Solution

When a child process terminates, SIGCHLD signal is sent to parent. waitpid function with WNOHANG flag can be used to check if a child process has terminated or is still running. Probably, you'll want to combine those both methods.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top