Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect new process creation instantly in linux

I am trying to create an application in userspace that sets affinity of processes. I would like the program to be triggered immediately every time a new pid/tid is spawned by the kernel. I am attempting to write to a file node under /proc from the do_fork() method in the kernel but I feel that it may have too much overhead.

Does anyone know any alternatives to detect a new process creation immediately after it is spawned?

If monitoring do_fork() is the way to go, would a call back to an userspace program via a system call be faster that using a fs node to communicate?

like image 384
theNoobProgrammer Avatar asked Nov 10 '14 20:11

theNoobProgrammer


1 Answers

Forkstat is a program that logs process fork() [among other things] Install it:

$ sudo apt-get install forkstat

Use it to log "fork" events:

$ forkstat -e fork
like image 74
Romain DEQUIDT Avatar answered Oct 12 '22 10:10

Romain DEQUIDT