mfork: closing kqueue file descriptor is unsuccessful and leads to 'assert failed' on OSX
Danappelxx opened this issue · 5 comments
Minimal program to reproduce:
#include <libmill.h>
int main(int argc, char *argv[]) {
goprepare(10, 25000, 300);
pid_t pid = mfork();
}
compiled with:
clang -o main main.c libmill.dylib -I/usr/local/include
output:
Assert failed: rc == 0 (./kqueue.inc:92)
Using libmill version 1.5 downloaded from the website and compiled with
./configure && make && sudo make install
I'm on OSX 10.11 running clang 7.3.0.
My knowledge of c is very limited but it seems like the assumption made about kqueue in the doc comment (here about how closing it will not return an error) is misguided.
As expected, if I get rid of the goprepare(10, 25000, 300)
the fork succeeds.
Let me know if there's anything I can do!
I don't own an OSX box. Can you possibly run the test in a debugger and check the value of 'errno' after the failed call?
Maybe we should include errno in the error message in these asserts?
Assert failed: rc == 0 (rc=2, errno=13 file=./kqueue.inc:92)
EACCESS. Interesting. I wonder whether that means that "file descriptor haven't survived the fork." Anyway, I'll try to fix it.
As for including errno into the asserts, yes, something like assert_errno() would be nice. I am to lazy to implement it though. So it's up to you :)
The problem is now fixed. Tested on OSX (via Travis) and FreeBSD.
Please check and close the ticket if everything goes OK.
Seems to work! Thanks for the quick fix :)