Show HN: Pact, a simple utility that kills all procs given to it if one dies
github.com
github.com
Basically you write simple shell script to start your processes and at the and you exec prace so it takes over children of shell:
#!/bin/sh
proc1 &
proc2 &
proc3 &
exec prace
You could also do this as a part of shell script in this way: (proc1 & proc2 & proc3 & exec prace)
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.
It doesn't kill the shell, when one of the process dies but kills the processes if shell dies. There is some trick involved in the way trap gets called though when shell dies and without waiting on the processes twice - shell exits without killing child processes.
[1] https://msdn.microsoft.com/en-us/library/windows/desktop/ms6...
pact --signal SIGINT $PID1 $PID2
pact -s SIGKILL $PID1 $PID2
pact $PID1 $PID2 # uses SIGTERM by defaultI debated about making it send SIGKILL shortly after sending SIGTERM, but I was having troubling thinking of an unsurprising way to implement it.
In my experience, processes doing IPC with parent gets notified of parental death by EOF on the socketpair/pipe it's using to communicate with the parent. This is easy to reason about and most people check return values from I/O functions. Parents spawning children and only caring about SIGCHLD are more prone to not have the correct signal handlers set up by its dev(s).
IMO, any process spawning children w/o proper signal handlers are not good citizens.
I can see how I would use it in supervisord within a group.
(A process monitoring system will mostly trigger under odd conditions... such as fork bombs.)
pact wakes up every second to check that every process is still there. If the process is gone, it sets the procChanged field in the struct, and it won't kill it later.
If allusions to suicide pacts are fair game, so is mass killing; and atomic means "all or nothing" in CS.
http://gatherer.wizards.com/Pages/Card/Details.aspx?multiver...
I wonder if there's anything in the rules to deal with the fact that a game might never complete.
Online play has what is effectively a chess clock. This doesn't work in person because the game involves "priority" passing between players after every single action, which would be difficult to do manually. Additionally, play in person relies on a whole bunch of "shortcuts" that skip steps if both players don't want to do anything, which would make timekeeping even more difficult.
But if you left out these tournament-specific rules and just played the game rules, you could have games going on arbitrarily long. Since you can create "tokens" you can have arbitrary amounts of state, so a game could even loop without ever hitting the same game state twice. (Think "puffer trains" from the John Conway's Game of Life.)