]> arthur.barton.de Git - bup.git/commit
Correctly pass along SIGINT to child processes.
authorAvery Pennarun <apenwarr@gmail.com>
Fri, 12 Mar 2010 23:05:54 +0000 (18:05 -0500)
committerAvery Pennarun <apenwarr@gmail.com>
Sat, 13 Mar 2010 02:41:02 +0000 (21:41 -0500)
commitb7a524ccb662c9ed3ebd786da0f45f459929ef45
treef44d416c166224f04597e29094825747765e078b
parentdbc9e3ec44b765860e7769d2084c609dfa246230
Correctly pass along SIGINT to child processes.

Ever since we introduced bup newliner, signal handling has been a little
screwy.  The problem is that ctrl-c is passed to *all* processes in the
process group, not just the parent, so everybody would start terminating at
the same time, with very messy results.

Two results were particularly annoying: git.PackWriter()'s destructor
wouldn't always get called (so half-finished packs would be lost instead of
kept so we don't need to backup the same stuff next time) and bup-newliner
would exit, so the stdout/stderr of a process that *did* try to clean up
would be lost, usually resulting in EPIPE, which killed the proces while
attempting to clean up.

The fix is simple: when starting a long-running subprocess, give it its own
session by calling os.setsid().  That way ctrl-c is only sent to the
toplevel 'bup' process, who can forward it as it should.

Next, fix bup's signal forwarding to actually forward the same signal as it
received, instead of always using SIGTERM.
lib/bup/client.py
main.py