diff options
author | Helmut Grohne <helmut@subdivi.de> | 2024-06-11 17:44:25 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2024-06-11 18:09:04 +0200 |
commit | a457a6c7c8fa17e0cec137c68a6a090edeb23e57 (patch) | |
tree | 25d09219e03643812a9cb4f98f0dcd9dcd61bb9d /examples | |
parent | e404a83f9225639636e1f955d0caf7df4df75cfe (diff) | |
download | python-linuxnamespaces-a457a6c7c8fa17e0cec137c68a6a090edeb23e57.tar.gz |
unschroot: synchronize reparenting
Before this change, it could happen that we'd call
prctl_set_child_subreaper before our parent actually died. Thus we'd
quickly get the death signal. The additional synchronization point
ensures that our previous parent process has been waited for (and thus
we are reparented) before installing the death signal.
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/unschroot.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/examples/unschroot.py b/examples/unschroot.py index 88c105f..3e3cc3a 100755 --- a/examples/unschroot.py +++ b/examples/unschroot.py @@ -228,6 +228,7 @@ def do_run_session(args: argparse.Namespace) -> None: os.setuid(spw.pw_uid) if not args.command: args.command.append("bash") + childsock.recv(1) linuxnamespaces.prctl_set_pdeathsig(signal.SIGTERM) if "PATH" not in os.environ: if spw.pw_uid == 0: @@ -244,6 +245,7 @@ def do_run_session(args: argparse.Namespace) -> None: pidfd = fds[0] os.waitpid(pid, 0) linuxnamespaces.prctl_set_child_subreaper(False) + mainsock.send(b"\0") sys.exit(os.waitid(os.P_PIDFD, pidfd, os.WEXITED).si_status) |