Notification of process termination

Notification of process termination

Post by Scott Strick » Fri, 09 Dec 1994 17:32:09

Is it possible to set up 2 applications so that the first will signal(?) the
second when it terminates?

I realize that in the case of a process forking a child process this happens
automatically in that the child generates a SIG_CHLD which the parent can

Is there any way to do the same (or similar) thing if there is no parent/child
relation between the 2 processes?

Several things we have thought of include the following:

Have the first process notify the second somehow prior to exiting.
   The problem with this is this only works if the first process can control
   when it exits.  It won't work if, for example, we do a kill -9 on the first

Set up signal handlers to catch all catchable signals and from within the
signal handler, notify the second process.
   The problem with this is; what do we do with uncatchable signals.

Periodically poll to see if the process still exists.
   Problems with this are that it takes a small amount of time to execute,
   and what if the PID is reused?

Any other thoughts would be greatly appreciated.  I feel that the solution
will be obvious, and hopefully easy to put in place, but cannot figure what
it might be.

Thanks in advance.


Grumman Data Systems
7600 Boston Blvd.
Springfield, VA 22153


Notification of process termination

Post by Rob McMah » Sun, 11 Dec 1994 22:20:32

>Periodically poll to see if the process still exists.
>   Problems with this are that it takes a small amount of time to execute,
>   and what if the PID is reused?

You can open /proc/<pid> and poll() on that ...




1. Q: Notification about termination of parent process.

Yes, but only in 2.2. It adds a prctl system call which supports this,
with something like:

#include <syscall.h>
#include <linux/prctl.h>

_syscall2(int, prctl, unsigned long, opt, unsigned long, arg)



(You'll need 2.2 headers installed for that to compile).

On 2.0 you have to poll, but to take advantage of 2.2 you can try
prctl and only poll if it returns -1 with errno == ENOSYS

(Perhaps glibc2.1 adds a prctl wrapper function, making the syscall
part unnecessary).

Dave Wragg

2. token ring sniffer

3. Notification about thread termination!

4. Casual User, 2.2.8 Install

5. Q: Notify device driver about process termination

6. ppp setup on standalone workstation

7. blocked process resists termination

8. Zeus Server

9. How do I suppress bkg. process termination messages?

10. BASH Process termination

11. signal of begining and termination of a runing process

12. Catching termination of child process and system() call

13. Driver driver peculiarity on process termination