Prev: UNIX SLIP
Next: Raw Socket
From: caiqian on
Hi,

I am tring to use the following code (test on Linux 2.6.16, glibc 2.4)
to generate SIGIO, but there is no signal. Is there anything wrong?

#include <stdio.h>
#include <signal.h>
#include <fcntl.h>

void
handle (int sig)
{
printf ("GET SIGIO\n");

}

int
main (void)
{
fcntl (0, F_SETFL, FASYNC);
fcntl (0, F_SETOWN, getpid ());
signal (SIGIO, handle);
write (1, "ls\n", 3);
sleep (1);
return 0;
}

Qian

From: Barry Margolin on
In article <1157316952.467904.156700(a)m79g2000cwm.googlegroups.com>,
caiqian(a)gmail.com wrote:

> Hi,
>
> I am tring to use the following code (test on Linux 2.6.16, glibc 2.4)
> to generate SIGIO, but there is no signal. Is there anything wrong?
>
> #include <stdio.h>
> #include <signal.h>
> #include <fcntl.h>
>
> void
> handle (int sig)
> {
> printf ("GET SIGIO\n");
>
> }
>
> int
> main (void)
> {
> fcntl (0, F_SETFL, FASYNC);
> fcntl (0, F_SETOWN, getpid ());
> signal (SIGIO, handle);
> write (1, "ls\n", 3);
> sleep (1);
> return 0;
> }
>
> Qian

Did you type anything while it was sleeping? You set async mode on
stdin, so you should only expect a signal when input is available on
that descriptor.

--
Barry Margolin, barmar(a)alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
 | 
Pages: 1
Prev: UNIX SLIP
Next: Raw Socket