From 3c534c54457f5cdd0eb8aa943b252fdc0b11f53a Mon Sep 17 00:00:00 2001 From: Alina Quereilhac Date: Sat, 6 Aug 2011 09:31:39 +0200 Subject: [PATCH] BugFix: Tixket #84 - [NEF] netns can't run with daemonized experiment controller. --- src/nepi/util/server.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/nepi/util/server.py b/src/nepi/util/server.py index 833d16b2..27930adb 100644 --- a/src/nepi/util/server.py +++ b/src/nepi/util/server.py @@ -200,7 +200,18 @@ class Server(object): return 1 def post_daemonize(self): - pass + # QT, for some strange reason, redefines the SIGCHILD handler to write + # a \0 to a fd (lets say fileno 'x'), when ever a SIGCHILD is received. + # Server dameonization closes all file descriptors from fileno '3', + # but the overloaded handler (inherited by the forked process) will + # keep trying to write the \0 to fileno 'x', which might have been reused + # after closing, for other operations. This is bad bad bad when fileno 'x' + # is in use for communication pouroses, because unexpected \0 start + # appearing in the communication messages... this is exactly what happens + # when using netns in daemonized form. Thus, be have no other alternative than + # restoring the SIGCHLD handler to the default here. + import signal + signal.signal(signal.SIGCHLD, signal.SIG_DFL) def loop(self): while not self._stop: -- 2.47.0