I wrote a simple daemon. This daemon should respond when I run any program. How to do this? In a big daemon loop:
while(1)
{
/* function which catches new programm running */
}
What functions to call in linux, when i'm running a new program (create new process)?
For Linux, there appears to be an interface in the kernel. Whilst researching this problem I came across people using CONFIG_CONNECTOR and CONFIG_PROC_EVENTS kernel configuration to get events on process death.
Some more google and I found this:
http://netsplit.com/2011/02/09/the-proc-connector-and-socket-filters/
The header of interest is:
I found example code here:
http://bewareofgeek.livejournal.com/2945.html
I found that this code needs to run as root to get the notifications.
The keyword for the search machine of your choice is "process event connector".
I found two tools that utilize them, exec-notify and cn_proc.
I like the later more, but both do their jobs very well.