Unix Programming - buffering SIGIO instances

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > June 2005 > buffering SIGIO instances





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author buffering SIGIO instances
Madhav

2005-06-28, 7:50 am

Hi all,

I am using the signal based model for reading data from a
socket.
That is, i am using fcntl() to raise a SIGIO whenever there is data to
be read from that socket. I want to know if i get many instances of
SIGIO ( ie could be raised by calling write() multiple times on the
socket descriptor ) are they buffered by default?
If they are not buffered, Is there any way to put the
signal on hold and later process it when i am inside a signal handler?

Thanks in advance for your help.

Madhav.

loic-dev@gmx.net

2005-06-28, 5:54 pm

Salut Madhav,

> I am using the signal based model for reading data from a
> socket.
> That is, i am using fcntl() to raise a SIGIO whenever there is data to
> be read from that socket. I want to know if i get many instances of
> SIGIO ( ie could be raised by calling write() multiple times on the
> socket descriptor ) are they buffered by default?


I am not an expert in that area, but AFAIK (on Linux) only real-time
signals are queued. SIGIO doesn't belong to that list.

> If they are not buffered, Is there any way to put the
> signal on hold and later process it when i am inside a signal handler?


Yes, it seems so. Accordingly to the fcntl() man page, use F_SETSIG and
instead of passing 0 (default: SIGIO), gives the signal you want. In
your case, choose any signal number comprised between SIGRTMIN and
SIGRTMAX.


HTH,
Loic.

Michael Kerrisk

2005-06-29, 2:48 am

On 28 Jun 2005 08:08:01 -0700, loic-dev@gmx.net wrote:

>Salut Madhav,
>
>
>I am not an expert in that area, but AFAIK (on Linux) only real-time
>signals are queued. SIGIO doesn't belong to that list.


Right.

>
>Yes, it seems so. Accordingly to the fcntl() man page, use F_SETSIG and
>instead of passing 0 (default: SIGIO), gives the signal you want. In
>your case, choose any signal number comprised between SIGRTMIN and
>SIGRTMAX.


Yes. Also, if Linux is your primary target, then it is worth getting
a recent copy of the manual pages (2.05) from
ftp://ftp.win.tue.nl/pub/linux-local/manpages/
and reading the fcntl(2) manual page to get information about various
useful (but non-portable) Linux-specific features for working with
signal-driven I/O.

Note also that there are limits on the number of real-time signals
that can be queued (things changed in Linux 2.6.7; see the signal(7)
and setrlimit(2) manual pages for details).

Having said all of this, you might want to consider using
select()/poll() or (the Linux-specific) epoll interface, since they
can be more convenient to work with than asynchronously delivered
signals.

Cheers,

Michael
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com