The following example program SEGVs in dirfd() in libc. Based on the manpage, it should be returning -1. #include <sys/types.h> #include <dirent.h> #include <stdlib.h> int main() { int fd = dirfd(NULL); }
The argument must be a pointer to a valid directory stream.
(In reply to comment #1) > The argument must be a pointer to a valid directory stream. ...and if it isn't libc should SEGV. That seems very illogical. It would seem to make much more sense to return -1 and set errno to EBADF.
You are mistaken in your expectation. Crashing is the very best thing to do and this is widely accepted. Do not reopen a bug for this behavior. Please seek advice on best practices for C interfaces elsewhere. This facility is for bugs in glibc. This is not one.