
c file (stream) input buffer problem help PLEASE!
I have a c I/O program that fputs's to a tty1 port connected to a
remote device and then fgets's from it for the response. It works
quite well.
Here is my problem. This program is called from a cgi script (perl
open w/pipe) to process a request from the script. If the client
escapes, the program gets cancelled fine but the data from the host is
still in the pipe.
I have put in signal traps to read through the response until it is
clear and then exit. This sort of works but not always.
Is there a way upon starting the program and opening the tty file that
it can be READ until there is NO data, then resume the normal flow???
I tried fflush'ing (NG) and fgets'ing but it just hangs.
Any recommendations will be IMMEDIATELY APPRECIATED>
Thanks.