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 06:44:04
Message-Id: 4D917F7D.5060601@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 08:07 PM, Perry Smith wrote:
2 >
3 > On Mar 28, 2011, at 9:49 PM, Zac Medico wrote:
4 >
5 >> On 03/28/2011 07:01 PM, Perry Smith wrote:
6 >>> 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.
7 >>>
8 >>> 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.)
9 >>>
10 >>> 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)
11 >>
12 >> In our case, a subprocess is connected to the slave end of the pty, and
13 >> portage reads its output from the master end. With Linux (among other
14 >> kernels), after the subprocess closes the slave end, we typically
15 >> receive a POLLHUP event or else EIO from a read call. Apparently, Linux
16 >> (among other kernels) we never receive a POLLERR event here, but with
17 >> AIX we do.
18 >
19 > I want to make sure you typed what you meant to type because it wasn't what I was expecting.
20 >
21 > Does the slave close first or the master? Or, I suppose, more importantly, which side (the master or the slave) is getting the POLLERR?
22
23 The slave does. This code works the same way as the "script" program
24 which is used to capture the output of a terminal session that is
25 attached to the slave end of a pty. Eventually, the subprocess that's
26 attached to the slave end exits, and that's presumably when the master
27 end receives the POLLERR event.
28
29 I should note that I assume that the POLLERR event occurs when the slave
30 end is closed, since the user has not reported any loss of subprocess
31 output. If the POLLERR event occurred before that, then output from the
32 subprocess would be lost.
33 --
34 Thanks,
35 Zac