pidfds: Return EINVAL for fasync

Matches latest Linux behavior.

The native pidfd test has also been deflaked.

PiperOrigin-RevId: 911141375
This commit is contained in:
Shailend Chand
2026-05-05 23:59:41 -07:00
committed by gVisor bot
parent 410668dd43
commit d5ef80320d
2 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ func (f *pidFD) Epollable() bool {
// RegisterFileAsyncHandler implements vfs.FileDescriptionImpl.RegisterFileAsyncHandler.
func (f *pidFD) RegisterFileAsyncHandler(fd *vfs.FileDescription) error {
return linuxerr.ENOTTY
return linuxerr.EINVAL
}
// UnregisterFileAsyncHandler implements vfs.FileDescriptionImpl.UnregisterFileAsyncHandler.
+9 -1
View File
@@ -1200,8 +1200,16 @@ TEST(PidfdTest, FasyncIsUnsupported) {
ASSERT_THAT(fcntl(pidfd.get(), F_SETFL, flags | FASYNC), SyscallSucceeds());
int who = getpid();
int want_errno = EINVAL;
if (!IsRunningOnGvisor()) {
KernelVersion version = ASSERT_NO_ERRNO_AND_VALUE(GetKernelVersion());
if (version.major < 6 || (version.major == 6 && version.minor < 9)) {
want_errno = ENOTTY;
}
}
EXPECT_THAT(ioctl(pidfd.get(), FIOSETOWN, &who),
SyscallFailsWithErrno(ENOTTY));
SyscallFailsWithErrno(want_errno));
}
} // namespace