I have the following code
fd_set set;
struct timeval timeout;
printf("first printf\n"); // displayed
FD_ZERO(&set);
timeout.tv_sec = 1;
FD_SET(fileno(stdout), &set);
if (select(FD_SETSIZE, NULL, &set, NULL, &timeout)!=1)
{
stdout_closed = true;
return;
}
printf("second printf\n"); // Not displayed
I m trying to check the ability to write to the stdout before printf("second printf\n");
. but with this code, the select return a value != 1
and then the printf remain unreacheable. it looks like the select return "not possible" to write to the stdout.
Could you explain this behavior?