Test-More / Test2-Harness

Alternative to Test::Harness
Other
23 stars 26 forks source link

Use setpgrp to isolate tests into their own pgrp #114

Closed aeruder closed 5 years ago

aeruder commented 5 years ago

When a new process is forked, it just inherit's its parent's pgrp. You can use setpgrp(0, 0) to get your own pgrp. The nice thing about pgrp's is that it makes it pretty easy to send signals to an entire pgrp.

Unfortunately there are modules (like MCE) that tend to send SIGINT to their own pgrp when they fail to aid in cleanup. In yath, this is kinda terrible, because yath and every test are sharing a pgrp = MCE kills every process currently running in yath including the main yath runner.

I think it makes sense to isolate each test into its own pgrp. In theory, yath can take advantage of this too. If it wants to send a SIGTERM to a test with PID $foo, it can instead do:

my $foo_pgrp = getpgrp $foo;
kill '-TERM', $foo_pgrp;

and send a SIGTERM to any forked processes too. Pretty cool.

exodist commented 5 years ago

merged a branch to fix this.