diff options
-rw-r--r-- | linuxnamespaces/__init__.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/linuxnamespaces/__init__.py b/linuxnamespaces/__init__.py index a39f43a..8adf45b 100644 --- a/linuxnamespaces/__init__.py +++ b/linuxnamespaces/__init__.py @@ -33,9 +33,12 @@ class run_in_fork: self.efd = EventFD() self.pid = os.fork() if self.pid == 0: - self.efd.read() - self.efd.close() - function() + try: + self.efd.read() + self.efd.close() + function() + except: + os._exit(1) os._exit(0) def start(self) -> None: @@ -80,9 +83,12 @@ class async_run_in_fork: self.efd = EventFD() self.pid = os.fork() if self.pid == 0: - self.efd.read() - self.efd.close() - function() + try: + self.efd.read() + self.efd.close() + function() + except: + os._exit(1) os._exit(0) watcher.add_child_handler(self.pid, self._child_callback) |