main
|
+-(fork:outer_helper) writes uid/gid for child process
| then notifies main that it's done by
| writing to a socketpair
+-(fork:cgroup_helper) waits for all sibling processes to
| terminate then cleans up the cgroup
main waits for outer_helper to do some setup and then outer_helper notifies main that it's done by writing an ok to a socketpair. If outer_helper dies before it gets a chance to write the ok message, that should be fine - main's end of the socketpair will close when all the references to the other side of the pair close. This normally happens as soon as outer_helper terminates because he as the only copy.
However, cgroup_helper also has a copy of that fd. It doesn't need it, so we should just close it as soon as that process starts.
Here's a little tree of processes:
main waits for outer_helper to do some setup and then outer_helper notifies main that it's done by writing an
ok
to a socketpair. If outer_helper dies before it gets a chance to write theok
message, that should be fine -main
's end of the socketpair will close when all the references to the other side of the pair close. This normally happens as soon as outer_helper terminates because he as the only copy.However, cgroup_helper also has a copy of that fd. It doesn't need it, so we should just close it as soon as that process starts.