cgroups: move our threads with us.
cgroups: move our threads with us.

Python stdlib generates some daemon threads in certain cases-
multiprocessing for example.  The problem here is that consuming code
doesn't have any real control over when this occurs.

Via cgroups manipulation, this means we can inadvertantly leave
threads behind.  This commonly forces cgroups shutdown code
into the hard kill pathway via the invoking process suppressing
SIGTERM (so it can do cleanup), but being unable to kill PIDs
that are actually it's own threads.

At some point, the code switches over to sigkill, and winds up
shooting itself in the head (in linux 2.4, you could sigterm/sigkill
individual threads; in w/ NPTL (2.6 and up basically), those signals
to child threads hit the main thread, taking out the entire group).

Thus we detect that scenario, and handle it accordingly.

This is the source of a pointless ~10s delay in shutdown we
experience, and up until the recent "disable cgroups in cbuildbot
inner", lead to it sigkill'ing itself.

Outer cbuildbot wasn't affected (it didn't execute pathways in
stdlib that lead to stdlib creating background threads).

BUG=chromium-os:30992
TEST=manual inspection, verification of cbuildbot no longer pausing
     unnecessarily, and injection of debug code to validate.

Change-Id: I3a853b12dcc4d709b6da11ada66bd58968d0563d
Reviewed-on: https://gerrit.chromium.org/gerrit/22925
Tested-by: Brian Harring <fdc2d0a2e2340b623587cee5ea8dff425d1eb1f3@chromium.org>
Reviewed-by: David James <f231dc574bbeb62604660cbc162d1b8642a0a3af@chromium.org>
Commit-Ready: Brian Harring <fdc2d0a2e2340b623587cee5ea8dff425d1eb1f3@chromium.org>

chadversary/chromiumos.chromite,coreos/chromite,chadversary/chromiumos.chromite,coreos/chromite,bpsinc-native/src_third_party_chromite,zhang0137/chromite,coreos/chromite,bpsinc-native/src_third_party_chromite,zhang0137/chromite,zhang0137/chromite,bpsinc-native/src_third_party_chromite