Comment by bluetomcat

Comment by bluetomcat 2 days ago

1 reply

> Programs should call close() on stdout and report errors.

Programs have never called open() to obtain stdin, stdout and stderr. They are inherited from the shell. What would be a meaningful way to report errors if the basic output streams are unreliable? If close(stdout) fails, we would need to write to stderr. Then you will have exactly the same error handling issue with closing stderr.

It's a flaw in the design of Unix where polymorphic behaviour is achieved through file descriptors. Worse is better...

marcosdumay 2 days ago

> It's a flaw in the design of Unix where polymorphic behaviour is achieved through file descriptors. Worse is better...

Looks to me it's a flaw on the signature of `write`. There should be a way to recover the status without changing the descriptor status, and there should be a way to ensure you get the final status, blocking if necessary.

This can even be fixed in a backwards compatible way, by creating a new pair of functions.