Web lists-archives.com

Re: Freeze opening /dev/stdout




On Fri, 20 Jul 2018 15:35:21 +0200
João Eiras wrote:
> #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.

I can't reporduce your problem.

The test case outputs:
Opened stdout: 3

$ ls -la /dev/std*
lrwxrwxrwx 1 yano なし 15 Mar 26  2016 /dev/stderr -> /proc/self/fd/2
lrwxrwxrwx 1 yano なし 15 Mar 26  2016 /dev/stdin -> /proc/self/fd/0
lrwxrwxrwx 1 yano なし 15 Mar 26  2016 /dev/stdout -> /proc/self/fd/1

What happens if you execute:
rm /dev/stdin /dev/stdout
ln -s /proc/self/fd/0 /dev/stdin
ln -s /proc/self/fd/1 /dev/output

-- 
Takashi Yano <takashi.yano@xxxxxxxxxxx>

--
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