open(O_ASYNC) is (still) broken in 2.6.3

From: Michael Kerrisk
Date: Thu Mar 04 2004 - 08:59:26 EST


Hello Andrew,

>From http://www.ussg.iu.edu/hypermail/linux/kernel/0111.1/1401.html and
http://www.ussg.iu.edu/hypermail/linux/kernel/0111.1/1636.html , I see that
this topic has been visited at least once before, but this behavior appears
still to be present in Linux 2.6.3.

The O_ASYNC flag has no affect (in terms of signal generation) when
specified in a call to open(). For example, if we make the following set of
calls:

fd = open("/dev/tty2", O_RDONLY | O_ASYNC);
fcntl(fd, F_SETOWN, getpid());

Then the call:

flags = fcntl(fd, F_GETFL);

tells us that O_ASYNC is in 'flags', but no signal is delivered when input
becomes available on the terminal. (We see the same behaviour if opening a
FIFO on 2.6.3.). On the other hand, the following does result in the
generation of SIGIO signals when input is available:

fd = open("/dev/tty2", O_RDONLY);
flags = fcntl(fd, F_GETFL);
fcntl(fd, F_SETFL, flags | O_ASYNC);
fcntl(fd, F_SETOWN, getpid());

Furthermore, the following sequence also results in generation of SIGIO when
input is available, but only after the final fcntl() call:

fd = open("/dev/tty2", O_RDONLY) | O_ASYNC;
fcntl(fd, F_SETOWN, getpid());
fcntl(fd, F_SETFL, 0);
fcntl(fd, F_SETFL, O_ASYNC);

I assume the patch referred to at the second URL above fixes this problem,
but I haven't tested it. The question is, why is this still broken?

Cheers,

Michael

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/