This is the mail archive of the cygwin-developers mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

poll()/select() on a tty fd in a backgrounded process raises SIGTTIN



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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]