From 2d52326035411ed8e280e858bf2ece001a6d0cce Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Sat, 18 May 2024 22:34:42 +0200 Subject: examples/netnsslirp.py: simplify termination of slirp4netns --- examples/netnsslirp.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'examples') 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"]) -- cgit v1.2.3