Re: Gnu c/c++: Alarm and read issue in linux

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

> My questions are:
> 
> 1. Should alarm() work with a system call like read()?

Yes, the signal handler should execute. After that the call should either
continue or break with errno=EINTR (I don't remember what was the
behaviour of signal() on Linux---better use sigaction() in which case you
can control this behaviour).

However, it only works if the driver cooperates properly with the kernel.


> 2. If not, is there any work-around?

Non-blocking I/O, asynchronous I/O, select(), but, again, they must be
supported by the driver.

If nothing else works, you can read the device in a subprocess and send 
the data to the main process via pipe (alarm() definitely works when you 
read() a pipe) or use threads.

Andres.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux