This is the mail archive of the cygwin mailing list for the Cygwin project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Mar 5 14:31, Corinna Vinschen wrote: > Hi Takashi, > > On Mar 5 21:53, Takashi Yano wrote: > > Package: cygwin > > Version: 1.7.35-1 > > > > PTY of cygwin dies when master fd in parent process > > is closed while a child process keeps valid master fd. > > > > To reproduce this problem: > > 1) Compile following C sources (Test Case 1, 2) > > 2) Execute them. > > > > Expected results are both: > > 01234567890 > > > > However, result of Test Case 2 is: > > Hungup > > while Test Case 1 is as expected. > > > > Difference between Test Case 1 and Test Case 2 is > > which process is worked in parent. In other words, > > master is in parent process in Test Case 1, while > > master is in child process in Test Case 2. > > > > I looked into cygwin source code, and found the cause. > > fhandler_pty_master::close() calls get_ttyp()->set_master_closed() > > if it is called from the process which opend the master. > > It is regardless whether other processes have the valid > > master handle. > > > > get_ttyp()->set_master_closed() should be called only > > when the last valid master handle among all processes > > is closed. > > No, I don't think so. The name of the method, set_master_closed() is > probably a bit misleading, as is the name of the test method > is_master_closed(). What it really means is this: > > The process creating the pty will start a master control thread (MCT). > This thread is used for duplicating handles from the slave side, if the > slave has no permissions to duplicate the from_master/to_master handles > by itself. The tty member master_pid points to the process running the > MCT. > > If the master fd is closed in the process having created the master, the > MCT is stopped as well. set_master_closed() sets master_pid to -1 to > reflect the fact that no MCT is running anymore. So, calling > set_master_closed() from close is not wrong, AFAICS. > > What's wrong is to test for is_master_closed() in fhandler_pty_slave::read, > and to generate SIGHUP in case the MCT isn't running. I think this code > snippet was a thinko, perhaps induced by the misleading name of the method. > > While looking through the code, I think that the second usage of > is_master_closed() (in fhandler_pty_slave::open()) is just as wrong... I applied a patch. Please have a look. Thanks. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat
Attachment:
pgpQAxDWYaDG0.pgp
Description: PGP signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |