Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] EbuildProcess logs poll-error to already removed $T (on AIX)
Date: Tue, 29 Mar 2011 02:50:04
Message-Id: 4D9148AB.8080702@gentoo.org
In Reply to: Re: [gentoo-portage-dev] EbuildProcess logs poll-error to already removed $T (on AIX) by Perry Smith
1 On 03/28/2011 07:01 PM, Perry Smith wrote:
2 > I did not 100% follow this. In particular, I didn't see how we started talking about pty's. But, since you are, I'll wade in.
3 >
4 > When the master side (the side that a daemon opens like telnetd) closes, the slave side gets the same treatment as if a modem hung up on a real tty. This is a SIGHUP *and* any further writes will return EIO (5) and further reads return 0. (All this is assuming CLOCAL is off.)
5 >
6 > I would not be surprised if the child process is receiving a SIGHUP if all the process session and controlling tty requirements have been met and the file descriptor is also selectable for POLLHUP and POLLERR. I would peek inside the Python code because perhaps it is testing for POLLERR before it is testing for POLLHUP. Or, perhaps it is not expecting the POLLERR at all (that is the 16384 value)
7
8 In our case, a subprocess is connected to the slave end of the pty, and
9 portage reads its output from the master end. With Linux (among other
10 kernels), after the subprocess closes the slave end, we typically
11 receive a POLLHUP event or else EIO from a read call. Apparently, Linux
12 (among other kernels) we never receive a POLLERR event here, but with
13 AIX we do.
14
15 > This should *not* be AIX specific but is actually POSIX standard.
16
17 When we receive POLLERR, we could try calling waitpid with WNOHANG on
18 the subprocess. If the process exits successfully at this point, then
19 it's probably safe to handle this case much like a POLLHUP even. For
20 this to work reliably, it seems like we will need to retry the waitpid
21 call in loop with some sleep calls, until the subprocess status becomes
22 available. If the status doesn't become available after a few seconds,
23 then we should probably try to kill the subprocess.
24 --
25 Thanks,
26 Zac

Replies