Are there files in the Linux filesystem that I could watch for changes on to monitor a process' status? In other words, is there a file that can be watched for fast process state change detection?
I would assume it'd be in the /proc directory, and what I'd like to do use use Node.js and the filesystem function fs.watch() to look for instant changes on a process' status. (Such as running, frozen, nonexistent, etc)
Is there a file that I can find a process' status in?
The current process state can be found in /proc/$PID/stat. This is the third field from man proc:
state %c One character from the string "RSDZTW" where R is running, S is sleeping in an interrupt‐ ible wait, D is waiting in uninterruptible disk sleep, Z is zombie, T is traced or stopped (on a signal), and W is paging.
Whether you can use file system watch functions on it is another matter, as /proc files aren't real files, but rather handles that generate data on demand.