Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com X-Envelope-Sender-Is: Andrej DOT Borsenkow AT mow DOT siemens DOT ru (at relayer david.siemens.de) From: "Andrej Borsenkow" To: "Cygwin mailing list" Subject: Possible parent/child race condition in accessing tty Date: Mon, 28 Aug 2000 20:21:31 +0400 Message-ID: <000201c0110c$069c7310$21c9ca95@mow.siemens.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 This strange hangup happens in one Zsh regression test. The problem is very sensitive to timing - if I insert some delays or run it under strace, everything runs. For this reason I am really at loss. Here is a description what happens: the Zsh test harness script (Zsh sript itself) starts another Zsh under pty control. Child closes all FDs (at least, it is expected to, unless there is a bug) and makes pty it's controlling tty. Master Zsh reads test file, for each test it feeds input to child Zsh, reads output and compares it with reference. This is done in a loop until all tests are done. When running tests, ps -l looks something like: mw1g017 AT MW1G17C% ps -l PID PPID PGID WINPID UID TTY STIME COMMAND 1404 1 1404 1404 1006 0 16:44:33 /usr/bin/bash 1516 1 1516 1516 1006 1 19:48:50 /usr/bin/zsh 1428 1404 1428 1268 1006 0 19:50:49 /usr/bin/make 1924 1428 1428 1960 1006 0 19:50:50 /usr/bin/sh 1816 1924 1428 1572 1006 0 19:50:50 /usr/bin/make 1036 1 1036 1036 1006 2 19:50:59 /usr/bin/zsh 2060 1816 1428 1540 1006 0 19:51:41 /usr/bin/sh 1820 2060 1428 2056 1006 0 19:51:41 /usr/build/zsh/Src/zsh 1780 1820 1780 1432 1006 3 19:51:44 /usr/build/zsh/Src/zsh 1000 1516 1000 1740 1006 1 19:51:51 /usr/bin/ps Here Zsh with PID 1820 is master Zsh and Zsh with PID 1780 is it's child that is running tests. When all tests are done, master writes "All tests sucessful" and excutes cleanup section that kills it's child by sending it HUP and closes master side of pty. What happens, is: - child disappears - but I do not see "All tests secceful" output; instead, master is waiting with TTOU flag: PID PPID PGID WINPID UID TTY STIME COMMAND 1404 1 1404 1404 1006 0 16:44:33 /usr/bin/bash 1516 1 1516 1516 1006 1 19:48:50 /usr/bin/zsh 1428 1404 1428 1268 1006 0 19:50:49 /usr/bin/make 1924 1428 1428 1960 1006 0 19:50:50 /usr/bin/sh 1816 1924 1428 1572 1006 0 19:50:50 /usr/bin/make 1036 1 1036 1036 1006 2 19:50:59 /usr/bin/zsh 2060 1816 1428 1540 1006 0 19:51:41 /usr/bin/sh O 1820 2060 1428 2056 1006 0 19:51:41 /usr/build/zsh/Src/zsh 1832 1516 1832 1276 1006 1 20:03:27 /usr/bin/ps Weird is, if I now try to do 'stty -a < /dev/tty00' from another window, this stty will hang, and I get the next (expected) line of output from master Zsh, and now I get another program hanging: after 'stty -a < /dev/tty00': PID PPID PGID WINPID UID TTY STIME COMMAND 1404 1 1404 1404 1006 0 16:44:33 /usr/bin/bash 1516 1 1516 1516 1006 1 19:48:50 /usr/bin/zsh 1428 1404 1428 1268 1006 0 19:50:49 /usr/bin/make 1924 1428 1428 1960 1006 0 19:50:50 /usr/bin/sh O 1816 1924 1428 1572 1006 0 19:50:50 /usr/bin/make 1036 1 1036 1036 1006 2 19:50:59 /usr/bin/zsh 1804 1036 1804 1704 1006 2 20:05:10 /usr/bin/stty 1540 1516 1540 1524 1006 1 20:05:16 /usr/bin/ps so, zsh exits and now make tries to write something and hangs. This is only stty; if I just try to access tty by opening it for reading, nothing happens. This is with current cygwin CVS. BTW now another older test hangup is fixed; thank you! I may be wrong, but I have seen Zsh test hangups at the same place before as well, somewhere around 1.1.2. Then tests stopped to work because of problem with pty that is fixed in post-1.1.4 CVS so I could not check it before. Thank you for any hint -andrej Have a nice DOS! B >> -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com