InstallProgress.waitChild spins if read fails immediately

Bug #53282 reported by Colin Watson
2
Affects Status Importance Assigned to Milestone
python-apt (Ubuntu)
Fix Released
Medium
Michael Vogt

Bug Description

    def waitChild(self):
        while True:
            (pid, res) = os.waitpid(self.child_pid,os.WNOHANG)
            if pid == self.child_pid:
                break
            self.updateInterface()
        return os.WEXITSTATUS(res)

In the event that the read() in updateInterface immediately returns EAGAIN (and by the way you should refer to that as errno.EAGAIN rather than as the hardcoded 11 and check errno.EWOULDBLOCK as well for compatibility with hppa etc.), then this will spin. select()ing on self.statusfd.fileno() would be much better, and you could install a SIGCHLD handler rather than checking with waitpid() every time.

Related branches

Revision history for this message
Colin Watson (cjwatson) wrote :

And, of course, because this file descriptor is non-blocking it spins nearly all the time. I bet fixing this would speed ubiquity's final stages up a fair bit; it would certainly make the strace a lot less noisy!

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks for those suggestions.

I added select() in waitChild() to make sure that it does not spin unnecessarly. It will timeout every 0.1s (default, can be changed via self.selectTimeout) to keep a possible GUI alive.

Cheers,
 Michael

The reason why waitChild() is implemented as a function and not as a signal handler is that e.g. vte does not work with that. It installs its own signal handler and you need to use the reaper object to catch children exiting.

Changed in python-apt:
assignee: nobody → mvo
importance: Untriaged → Medium
status: Unconfirmed → Fix Committed
Michael Vogt (mvo)
Changed in python-apt:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.