Freeze opening /dev/stdout

João Eiras joao.eiras@gmail.com
Fri Jul 20 16:08:00 GMT 2018


Hi.

On linux now and then I call a program passing "/dev/stdout" as output
file parameter, so the data is output in the terminal.

For instance, something tiny in C.

#include <fcntl.h>
#include <stdio.h>
int main () {
int fd = open("/dev/stdout", O_WRONLY);
printf("Opened stdout: %d\n", fd);
return 0;
}

Unfortunately, this freezes. The problem (I think) is because
/dev/stdout is a pipe, so the open() call waits forever until a
reader() opens /dev/stdout, which in this case should be the terminal.

Interestingly, this does not affect /dev/stderr which is a link to the
console device.

$ ls -la /dev/std*
lrwxrwxrwx 1 user None 15 Sep  6  2017 /dev/stderr -> /proc/self/fd/2
prw------- 1 user None  0 Jun  4 15:54 /dev/stdin
prw------- 1 user None  0 Jun  4 15:54 /dev/stdout

I've just sent another thread about "/dev/stdin" always being a pipe,
so I guess that is related.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list