This is the mail archive of the
mailing list for the Cygwin project.
Re: Kill cygwin process form task manager
On Nov 14, 2008 10:20am, Michael Wiedmann wrote:
> I need hints how to act if someone kills my Cygwin (parent) process using Windows task manager and I want to kill all forked child processes.
> I already keep a list of all childs pids and can kill them successfully in an SIGINT handler (if the programm is started in foreground and is interrupted e.g. by Ctrl-C).
Untested on Cygwin, but works on Linux, etc.:
1. Create an anonymous pipe using the pipe function.
2. Fork the child.
3. Close the read fd in the parent and the write fd in the child.
4. Have child select on the read fd.
5. When the parent dies the select will return.
6. Try to read from the pipe. If read returns 0, i.e. end-of-file the
parent is dead.
Alternatively, do it the other way round, with the child occasionally
writing to the pipe and the parent draining it. The child will get
SIGPIPE when the parent dies.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html