Bug 195711 - signal(7) says read(2) from an inotify(7) fd is never restarted but it's wrong
Summary: signal(7) says read(2) from an inotify(7) fd is never restarted but it's wrong
Status: RESOLVED CODE_FIX
Alias: None
Product: Documentation
Classification: Unclassified
Component: man-pages (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: documentation_man-pages@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-11 05:57 UTC by lilydjwg
Modified: 2017-05-30 03:51 UTC (History)
1 user (show)

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description lilydjwg 2017-05-11 05:57:32 UTC
signal(7) says:

> The following interfaces are never restarted after being interrupted by a
> signal handler, regardless of the use of SA_RESTART; they always fail with
> the error EINTR when interrupted by a signal handler:
> [...]
> * read(2) from an inotify(7) file descriptor.

But it's not the case. If I use signal(2) or sigaction(2) with SA_RESTART, I can't interrupt a read(2) for an inotify(7) fd. If I remove the SA_RESTART, it's interrupted as expected.

And in the kernel code fs/notify/inotify/inotify_user.c, inotify_read returns -ERESTARTSYS when there are pending signals.
Comment 1 Michael Kerrisk 2017-05-30 03:51:00 UTC
(In reply to lilydjwg from comment #0)
> signal(7) says:
> 
> > The following interfaces are never restarted after being interrupted by a
> > signal handler, regardless of the use of SA_RESTART; they always fail with
> > the error EINTR when interrupted by a signal handler:
> > [...]
> > * read(2) from an inotify(7) file descriptor.
> 
> But it's not the case. If I use signal(2) or sigaction(2) with SA_RESTART, I
> can't interrupt a read(2) for an inotify(7) fd. If I remove the SA_RESTART,
> it's interrupted as expected.
> 
> And in the kernel code fs/notify/inotify/inotify_user.c, inotify_read
> returns -ERESTARTSYS when there are pending signals.

Thanks for the report. It seems things changed in Linux 3.8. The man-page was correct for earlier kernel versions. I've amended the man-page text to list this case as restartable with SA_RESTART:

       * read(2) from an inotify(7) file  descriptor  (since  Linux  3.8;
         beforehand, always failed with EINTR).

I'll close this bug now.

Note You need to log in before you can comment on or make changes to this bug.