@johnregehr stdin, stdout, stderr
0 1 2
-
-
- View other replies
-
@whitequark I know-- I'm asking why writing to stdin works -
@whitequark actually writing to stdin does not work (on my system at least) but writing to fd 0 does work - View other replies
-
@johnregehr oh, WRITING it's /dev/pts/1 opened guess konsole or getty opens it as O_RDWR. -
@whitequark I just find it odd that this program prints 1 line instead of 0 or 2 http://pastebin.com/EpCQbqDg -
@johnregehr I guess FILE duplicates the open flags? -
@johnregehr I could look at glibc or wherever in the kernel fds happen but you'd need to motivate me to do that -
@whitequark not so much interested in the implementation than the reasoning behind it - Show more
-
-
-
@johnregehr What is file descriptor 0 pointed at when this happens? I think I know the answer for the case it's a tty, but not otherwise. -
@elwoz works the same when running "foo 0> output" - View other replies
-
@johnregehr In that case you should be able to write *but not read* stdin. If you can read it, that's a bug in your shell. -
@elwoz can definitely read and write fd 0 in the same process (on my mac) -
@johnregehr If you can do that with "0>output", it's a bug in the shell. -
@elwoz only works from console looks like - View other replies
-
@johnregehr OK, so that's the tty case I was thinking of. It was probably opened once, O_RDWR, then dup'ed onto 0/1/2.
-
-
-
@johnregehr Isn't it the same as stdin? Why wouldn't writing to it work? - View other replies
-
@ErrataRob but why should it work? should I also be able to read from stdout? where would the data that I get come from? -
@johnregehr The other end of the pipe. I don't know, but I assume the shell does the standard create pipe for each one, then fork(3) -
@ErrataRob when I write pipe code I always close the "wrong" ends -- maybe bash authors don't agree... -
@johnregehr Write a test program that pipe/forks/execs another program that writes stdin and reads stdout.... -
@johnregehr ...then see if closing the ends makes a difference.
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
John Regehr
chocolate hornet
zing web creak
Robert Graham