Who else is using that tty?
-
-
-
The shell that you invoked the program from.
-
And all future commands/programs you run on the tty.
-
And stdin/stdout tend to be the same tty...
End of conversation
New conversation -
-
-
I guess because the file description is likely shared between child and parent processes? And so if the child unexpectedly terminates (or backgrounds) then the parent is left with stdin in non-blocking mode, which it doesn't know how to deal with?
-
Yep, exactly. It's unexpectedly (due to programmer confusion about file descriptors vs descriptions) modifying shared state. Try in an interactive shell, and "read x" after the program exits.
End of conversation
New conversation -
-
-
It can make your cat sick.
$cat cat: -: Resource temporarily unavailableThanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
I've been considering the ability to create a copy of a file description pointing to the same underlying file. The Sortix kernel can do it, no problem, just not exposed in any syscall. An open question is whether it will have unintended consequences.
-
Linux does just that if you `open()` the filedescriptor's file in `/dev/fd`.
-
That's a good point, I didn't realize that was possible. It's non-portable though and I don't really like to magic filesystem features (though admittedly convenient now and then).
-
I wonder if there's any subtleties in how /dev/fd is implemented. E.g. imagine a file open for reading, but the user cannot open it anymore (unlinked / parent directory access denied), but the file mode allows writing, so /dev/fd lets you reopen for writing. Expected? Probably?
-
What if the unlinked file descriptor was sent over a Unix domain socket, and was intended to contain immutable data? But then both ends would be running as the same user. And I guess the sender could fchmod it 000 after opening it. Interesting cases to consider.
-
Well I guess the receiver could fchmod it 700 again unless the sender fchown'd it (but then sender has to be root).
End of conversation
New conversation -
-
-
because any duplication of 0 to other fds or processes breaks?
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
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.