This is the mail archive of the
cygwin-developers
mailing list for the Cygwin project.
poll()/select() on a tty fd in a backgrounded process raises SIGTTIN
- From: Jon Turney <jon dot turney at dronecode dot org dot uk>
- To: cygwin-developers at cygwin dot com
- Date: Mon, 25 Jul 2016 11:15:18 +0100
- Subject: poll()/select() on a tty fd in a backgrounded process raises SIGTTIN
- Authentication-results: sourceware.org; auth=none
Consider the following:
$ cat sigttin-test.c
#include <unistd.h>
#include <poll.h>
// gcc sigttin-test.c -o sigttin-test
// ./sigttin-test &
int main()
{
// poll stdin
struct pollfd fds;
fds.fd = STDIN_FILENO;
fds.events = POLLIN;
return poll (&fds, 1, 0);
}
$ gcc sigttin-test.c -o sigttin-test
on cygwin:
$ ./sigttin-test &
[1] 6120
[1]+ Stopped ./sigttin-test
$ jobs -l
[1]+ 6120 Stopped (tty input) ./sigttin-test
on linux:
$ ./sigttin-test &
[1] 2779
$
My reading seems to indicate that SIGTTIN should be raised when read()
is made on a tty in a backgrounded process, not when it's polled, but
looking at the Cygwin source code, it's been this way since the earliest
versions in git...
This test case is reduced from a problem seen with gdb, since commit
0b333c5e, where gdb stops with SIGTTIN when the inferior is started.