简体   繁体   中英

Linux: how to program to monitor process existing/quiting?

SIGCHLD can only be caught by father process to monitor if child process exits. But I wish to write a stand-alone program to monitor some processes, if they quit, report a log immediately.

Is there any programming ways that I can use, rather than using a shell "ps" command to monitor process name/id, and then query in a dead loop?

You can monitor process activity through proc pseudo-filesystem usually mounted at /proc. For reference use: https://www.kernel.org/doc/Documentation/filesystems/proc.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM