can someone provide an example, where if the parent process quits for any reason, then the child process will also close?
can someone provide an example, where if the parent process quits for any reason, then the child process will also close?
On what OS?
I'm assuming this is Linux or some *NIX. IIRC from something I read here, Windows doesn't keep a process hierarchy, everything is a "child" of the master process (the equivalent of init in Linux). In Linux, if the parent process dies, the OS will reap all the children, and their new parent will be init. They will be allowed to finish normally. Generally the parent wants to wait for it's children, using the wait/waitpid functions.
The way around this is to track all your children and kill them by sending SIGKILL to their process numbers. That means you will probably need a special signal handler in the child processes that catches the SIGKILL signal, cleans up accordingly and sends a SIGKILL to any child processes it may have, etc.
yeah its linux, and i want to end the child because of an infinite loop, so it would really help if you can provide an example of how to do the signal code.
As well if you do know, i am trying to combine a select code (using socket fd's) with a pipe fd, but its not working, if you can also show an example of that, it would be very helpful
I don't feel like writing you a tutorial. From your console/terminal, type "man 2 signal", "man 2 sigaction" and "man 2 kill". That should give you a start into sending and handling signals. Google around for "C signal handling in Linux", and you should get some decent results.
That's really vague. I'm not sure how you plan to use the two together, so I couldn't write you a useful example even if I wanted to. Again, Google around, and make sure you fully understand both select and pipes before combining them.As well if you do know, i am trying to combine a select code (using socket fd's) with a pipe fd, but its not working, if you can also show an example of that, it would be very helpful
If you have specific questions about either of these, post back with some code you've tried, and the exact problem, and we'll gladly help you out.