public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Freeze opening /dev/stdout
@ 2018-07-20 16:08 João Eiras
  2018-07-21  7:04 ` Takashi Yano
  0 siblings, 1 reply; 5+ messages in thread
From: João Eiras @ 2018-07-20 16:08 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-07-21 14:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-20 16:08 Freeze opening /dev/stdout João Eiras
2018-07-21  7:04 ` Takashi Yano
2018-07-21 11:30   ` Marco Atzeri
2018-07-21 14:56   ` Takashi Yano
2018-07-21 19:22     ` João Eiras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).