EventLoop: fix signal race in _sigchld_init
authorZac Medico <zmedico@gentoo.org>
Thu, 16 Feb 2012 21:42:59 +0000 (13:42 -0800)
committerZac Medico <zmedico@gentoo.org>
Thu, 16 Feb 2012 21:42:59 +0000 (13:42 -0800)
pym/portage/util/_eventloop/EventLoop.py

index 3123cab668812330ee0a06887ff253ad9c768788..9ca529fe11fbcb72b6eb8d8ff9e2ddab1203d316 100644 (file)
@@ -242,11 +242,11 @@ class EventLoop(object):
                return source_id
 
        def _sigchld_init(self):
-               signal.signal(signal.SIGCHLD, self._sigchld_sig_cb)
                self._sigchld_read, self._sigchld_write = os.pipe()
                fcntl.fcntl(self._sigchld_read, fcntl.F_SETFL,
                        fcntl.fcntl(self._sigchld_read, fcntl.F_GETFL) | os.O_NONBLOCK)
                self.io_add_watch(self._sigchld_read, self.IO_IN, self._sigchld_io_cb)
+               signal.signal(signal.SIGCHLD, self._sigchld_sig_cb)
 
        def _sigchld_sig_cb(self, signum, frame):
                # If this signal handler was not installed by the