This is the mail archive of the cygwin@sources.redhat.com 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]

Possible parent/child race condition in accessing tty


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@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@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]