TIL: glibc writes internal error messages directly to /dev/tty (!) and when it can't it sometimes writes to STDERR_FILENO (probably, but not always, stderr). See https://github.com/lattera/glibc/blob/a2f34833b1042d5d8eeb263b4cf4caaea138c4ad/sysdeps/posix/libc_fatal.c#L62-L69 …. Takeaway #1: Never `close(STDERR_FILENO);` Instead reopen /dev/null using STDERR_FILENO.
-
-
Takeaway #3: Sandboxing frameworks need to deal with this issue in some way. They can't blindly block syscalls like `dup2()` or completely block `/dev/null` unless they've otherwise already ensured that STDERR_FILENO is always a valid file descriptor that is safe to write to.
Show this thread -
Takeaway #4: If you're developing an operating system with POSIX-y stdin/stdout/stderr stuff, don't ever implicitly reuse STD*_FILENO file descriptors after those file descriptors have been closed.
Show this thread
End of conversation
New conversation -
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.