design patterns - C++ signal listener for non-child pid -


i'm using c++ , need equivalent of sigchld process i'm aware of (i.e. know it's pid), did not spawn.

is there established design pattern listen/watch/monitor process's lifespan when not child or in group or session?

edit: trying aware of abnormal terminations (i.e. seg faults, signals, etc...). eavesdrop on signals process in question receives.

i don't know if follows specific pattern, per se, 1 technique have process establish connection watcher. watcher monitors connection, , when becomes closed, knows process has shutdown.

if watcher wants know if watched process responsive or not, can use connection monitor heartbeat messages process obliged provide.

if watcher wants know whether watched process making progress, heartbeat message provide state information allow watcher monitor that.

different operating systems may provide different ways achieve same objective. example, on linux, watcher use inotify monitor /proc entry process determine if process or down. bsd kqueue has similar capability. process export heartbeat/state shared memory, , watcher use timed wait on semaphore see if data being updated.

if process third-party program, , source not available, have resort method similar inotify/kqueue, or last resort, poll kernel state (similar way top utility works).


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -