Hi list, I'm having trouble sending data back and forth between two processes over a pseudo terminal. I'm able to send data from the slave tty to the master pty without any problem. However, no data can be read from the slave side of the pty (tty). I've attached an example program that demonstrates my problem. I compiled it with
gcc ptyrw.c -g -o ptyrw -Wall I have cygwin version 1.3.22-1 (Curr in setup as of yesterday). I've attempted to follow the suggestions made in earlier discussions of pseudo terminals (http://sources.redhat.com/ml/cygwin/2002-11/msg00064.html for example). Has anyone written an example of a working pty/tty connection under Cygwin? I would appreciate it very much if someone could set me straight on this. The output I'm getting with my test program is as follows: $ ./ptyrw MASTER: Master Alive: My PID: 232 << Master writing to Slave >> *Max Read Size: 2147483647 MASTER: Created master pty: 3 MASTER: Associated Slave: /dev/tty0 MASTER: Forking Slave... MASTER: Preparing to write: Sleeping for 2 to let slave get set up SLAVE: Slave Alive: My PID: 128 SLAVE: Setting Session ID SLAVE: Opening slave end of pty SLAVE: Preparing to read, sleeping for 5 while master writes MASTER: Writing "Master Send" MASTER: Wrote 15 bytes: "Master Send" MASTER: Sleeping for 10 while slave finishes SLAVE: Attempting to read from fd 4 READERROR: Data did not become available in 3 seconds SLAVE: Read Error SLAVE: Quitting... MASTER: Quitting... Whereas in this direction things work as expected: $ ./ptyrw 1 MASTER: Master Alive: My PID: 1124 << Slave writing to Master >> *Max Read Size: 2147483647 MASTER: Created master pty: 3 MASTER: Associated Slave: /dev/tty0 MASTER: Forking Slave... MASTER: Preparing to read, sleeping for 5 while slave writes SLAVE: Slave Alive: My PID: 1896 SLAVE: Setting Session ID SLAVE: Opening slave end of pty SLAVE: Wrote 15 bytes: "Slave Send" SLAVE: Sleeping for 10 while master finishes MASTER: Attempting to read from fd 3 MASTER: Read 7 bytes: "Slave S" MASTER: Sleeping for 10 while slave finishes SLAVE: Quitting... MASTER: Quitting... The fact that read returns data in blocks of 7 bytes or less seems a bit cumbersome but not out of spec. Thank you very much for any suggestions. Matt Hirsch
ptyrw.c
Description: Binary data
-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/