This is the mail archive of the cygwin 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]

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@nifty.ne.jp>

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


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