Re: [patch] fcntl.2: Add ESRCH to list of ERRORS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Paul,

On 3/10/22 17:28, Paul Bergmann wrote:
> Hello everyone,
> 
> when setting the notified PID for async operations using F_SETOWN
> (F_SETOWN_EX respectively), the operation may fail if no process with

I think s/may/will/ w

> the specified PID is alive and visible to the caller. In this case, the
> errno is set to ESRCH. This was introduced in the kernel by
> f73127356f344483c82632accda2e72b7e0e5f25.
> 
> Here is an example program showing this behavior
> 
> setown_nonexisting.c:
> 
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> static void die(const char *msg)
> {
>     perror(msg);
>     exit(EXIT_FAILURE);
> }

Just in case you didn't know, there's err(3) in <err.h> which is very
close to this :)

> 
> int main(void)
> {
>     int fd = open("/dev/null", O_RDONLY | O_ASYNC);
>     if (fd < 0) {
>         die("open");>     }
>     /* Assuming there is no process with PID 999999 */
>     if (fcntl(fd, F_SETOWN, 999999) < 0) {
>         die("fcntl");
>     }
>     return EXIT_SUCCESS;
> }
> 
> $ cc ./setown_nonexisting.c
> $ ./a.out
> fcntl: No such process
> 
> I hope my patch is according to the standards.

Please add patches inline if you can (or both inline and attached if
inline is likely to fail), but inline is easier to quote and reply.

> 
> Best regards
> Paul Bergmann

Please sign the patch with "Signed-off-by: ..."
<https://www.kernel.org/doc/man-pages/patches.html>

> ---
>  man2/fcntl.2 | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/man2/fcntl.2 b/man2/fcntl.2
> index 7b5604e3a..18651321f 100644
> --- a/man2/fcntl.2
> +++ b/man2/fcntl.2
> @@ -1827,6 +1827,18 @@ but
>  was not open for writing
>  or the current set of seals on the file already includes
>  .BR F_SEAL_SEAL .
> +.TP
> +.B ESRCH
> +.I cmd
> +was
> +.BR F_SETOWN
> +(
> +.BR F_SETOWN_EX
> +) and
> +.I arg
> +(
> +.I arg->pid
> +) does not refer to a visible process.


The parentheses are slightly incorrect.
You could check the rendered page.
The patch should be written as


+.TP
+.B ESRCH
+.I cmd
+was
+.B F_SETOWN
+.RB ( F_SETOWN_EX )
+and
+.I arg
+.RI ( arg->pid )
+does not refer to a visible process.

Check groff_man(7) and/or man(7).

I think I'd also add "or" inside the parentheses to make it a bit more
readable:

+.TP
+.B ESRCH
+.I cmd
+was
+.B F_SETOWN
+(or
+.BR F_SETOWN_EX )
+and
+.I arg
+(or
+.IR arg->pid )
+does not refer to a visible process.


Thanks,

Alex


-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux