Re: fcntl questions
Re: fcntl questions
- Subject: Re: fcntl questions
- From: Terry Lambert <email@hidden>
- Date: Sun, 04 Nov 2007 12:45:22 -0800
On Nov 4, 2007, at 9:30 AM, Steve Checkoway <email@hidden> wrote:
On Nov 4, 2007, at 7:32 AM, Thierry Passeron wrote:
The reason why they use SIGRTMIN + x in the linux example is that
they use the possibility to get some si_fd extra member in the
siginfo_t struct passed as argument to the signal handler installed
with sigaction(). And so it is possible to know which descriptor
became ready when the signal was sent (no need to use select() in
the signal handler)
I have not found this si_fd member in the Darwin siginfo_t structure.
So how can I proceed ? I know I could use the default signals SIGIO/
SIGURG and use a select() in the signal handler to check which
descriptor are available for reading now.
I can't answer all of your questions but the only functions you
should call in a signal handler are those listed in the sigaction
man page. select(2) is not among them.
If I were doing this and I really needed to not block in select, I'd
either catch the SIGIO signal and set a flag (which is about all you
should ever do in a signal handler) which I would check each time
through a loop and when it is set, I'd use select with a zero
timeout to get the pipes that need to be read from and then read
from them.
Of course, I don't know how often one gets that signal. I would
think it would be easier to either use poll(2) or select(2) each
time through the loop to be sure I was catching all of the data that
was ready to read.
Use a separate thread, if you are unwilling to mux all your events
through a workloop or a kqueue or a workqueue.
MacOS X does not support POSIX real time signals due to binary
compatibility issues, and due to not a lot of perceived gain for our
developers other than easing porting of the small amount of code that
depends on them.
Your code should:
#include <unistd.h>
...
#if defined(_POSIX_REALTIME_SIGNALS) && (_POSIX_REALTIME_SIGNALS
>= 200112L)
/* my code relying on the new extension here */
...
#else
/* my portable code here */
#endif
-- Terry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden