Re:Show HN: Pact, a simple utility that kills all procs give...
by hmpc on Friday January 22, 2016 @05:49AM
(#10951987)
This is the service supervision approach, which is indeed the best, avoiding race conditions and nasty polling. If you really must monitor processes which you cannot parent, at least under Linux you can do this using ptrace to sort-of-reparent the processes (as long as you have CAP_SYS_PTRACE or your ptrace scope is set to 0 in Yama), with waitpid to monitor all of them.
Re:Show HN: Pact, a simple utility that kills all procs give...
by gkya on Friday January 22, 2016 @08:02AM
(#10952428)
I for one would like to have it at hand, if you could. Just paste it here if you don't mind publishing it, thanks in advance.
Re:Show HN: Pact, a simple utility that kills all procs give...
by hawski on Saturday January 23, 2016 @02:07PM
(#10959547)
For the time being I can't access original implementation, but quick and dirty version looks like this: https://gist.github.com/hadrianw/8e6f9c1007953b37f768
Basically you write simple shell script to start your processes and at the and you exec prace so it takes over children of shell:
You could also do this as a part of shell script in this way: Then prace has simple job. It wait(2)s and then kills all children.I have it somewhere if someone is interested, but I can access it in few hours. But everything is written in at most 2/3 terminal screens worth of C.