My interpretation of the POSIX spec is that write() either succeeds
or fails. If you give it a bad pointer as the second argument,
or a size for the third argument that exceeds the available data
pointed to by the second argument, the behavior is undefined.
But if you pass 0 (standard input) as the first argument, that's
a valid file descriptor argument -- just one you might not have
*permission* to write to.
Quoting the POSIX spec
(
http://pubs.opengroup.org/onlinepubs/9699919799/toc.htm):
These functions shall fail if:
...
[EBADF]
The fildes argument is not a valid file descriptor open for
writing.
That looks pretty well-defined to me.
The implementation *might* be non-conforming because it permits
writes to standard input, but I don't see any permission for the
implementation to throw up its hands and unleash the nasal demons.
I'd have to look further to determine whether 0 may be considered
to be "open for writing"; searching the spec for "0" is unlikely
to be useful.