eventfd using EFD_SEMAPHORE fails with EINVAL (Invalid argument)
eventfd appears to work fine using EFD_CLOEXEC | EFD_NONBLOCK but once EFD_SEMAPHORE is included then EINVAL is returned.
The attached zip should contain a cpp file demonstrating the issue. It should also include an strace of the actual execution.
Thanks for reporting the issue, the EFD_SEMAPHORE flag is not currently supported by WSL. Outside of the targeted test, did you hit this in a particular application or scenario?
In this scenario it was an application I'm working on myself. I'm using the eventfd as a convenient "interrupt" mechanism for a select call that is waiting for read ready on one or more file descriptors.
The facebook folly library appears to do something similar in its libevent wrapper but they must be doing some ifdef magic to avoid any incompatible environments (it seems to work fine.)
I don't think the EFD_SEMAPHORE option is strictly necessary for my usage so I can get around it for now. Thanks for the heads up.
I appreciate all the work you guys are doing on this!
Thanks I'll close this out for now and add the feature tag.
We need EFD_SEMAPHORE in WSL, so how to reopen this issue?
EFD_SEMAPHORE was actually added recently and the fix should be out in insider builds soon.