diff options
author | Helmut Grohne <helmut@subdivi.de> | 2024-05-18 22:34:42 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2024-05-18 22:34:42 +0200 |
commit | 2d52326035411ed8e280e858bf2ece001a6d0cce (patch) | |
tree | 8e48698f2fca8e8db42b9f5a4d499b83e044a384 /examples | |
parent | 056c1f964f55adedc17f8d7bddef1f48c73852c7 (diff) | |
download | python-linuxnamespaces-2d52326035411ed8e280e858bf2ece001a6d0cce.tar.gz |
examples/netnsslirp.py: simplify termination of slirp4netns
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/netnsslirp.py | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/examples/netnsslirp.py b/examples/netnsslirp.py index 0818fba..7a1a27e 100755 --- a/examples/netnsslirp.py +++ b/examples/netnsslirp.py @@ -6,6 +6,7 @@ """ import os +import signal import sys if __file__.split("/")[-2:-1] == ["examples"]: @@ -16,14 +17,11 @@ import linuxnamespaces def main() -> None: mainpid = os.getpid() - rfd, wfd = os.pipe() if os.fork() == 0: - os.set_inheritable(rfd, True) + linuxnamespaces.prctl_set_pdeathsig(signal.SIGTERM) os.execlp( "slirp4netns", "slirp4netns", - "--exit-fd", - "%d" % rfd, "--configure", "--disable-host-loopback", "%d" % mainpid, @@ -35,9 +33,6 @@ def main() -> None: 0, linuxnamespaces.CloneFlags.NEWUSER | linuxnamespaces.CloneFlags.NEWNET, ) - # Leave write end of --exit-fd behind as fd 252. - os.dup2(wfd, 252) - os.close(wfd) os.execlp(os.environ["SHELL"], os.environ["SHELL"]) |