I am writing a wrapper application to bash scripts and want the application to keep a track of which tools/processes have been launched from user scripts. I would like to know what is the best way to determine the list of child processes that were spawned of this parent process.
I tried
- Periodically invoking psps command and building a process tree (like ps -ejH) but this misses out on processes that ran to completion very quickly.
- Using a tool like forkstatforkstat that uses the proc connector interface, but that would only run with elevated privileges. While this gives the correct data, running as sudo would not work in my case?
Any suggestions how this can be achieved?