|No such thing as a small change|
Handling I/O Signalsby stephane (Monk)
|on Mar 13, 2002 at 20:01 UTC||Need Help??|
stephane has asked for the wisdom of the Perl Monks concerning the following question:
Currently I have a problem catching (or handling) SIGIOs in a Perl script. What I would like to achieve, is to have a small script reading and writing to a serial port whithout the need to poll it every now and then to see if there is indeed something to read.
A SIGIO handler is set a the beginning of the script, which right now just prints out a string when an IO signal has been caught. sigtrap is there just in case other type of signals are sent (apperently not the case anyway).
Once all that is done ;-) it will write something on the line and wait for the signal(s) - I verified that the device indeed answers ("OK" in this case).
The problem is: no SIGIOs are sent back..
More precisely, if the script just waits (as it does in the above code) no SIGIOs will be catched. Instead, if (at some point) I start reading what is on the port (meaning: modify the script to actualkly read something at some point).. then the SIGIO_Handler will be used.
So, I dont want the signals to tell me that I am reading on the port.. I want them to tell me that there is something to read in the first place! (before I actually read it "myself").
Can somebody provide any hints/advice?
P.S.: by the way, I don't want to use the Device::SerialPort since I have the feeling that it should be possible through POSIX and Fcntl and they are in the standard distribution, or even Win32::SerialPort for the allready given reasons, plus.. Im on Linux (kernel v2.2)