[Bug 215769] man 2 vfork() does not document corner case when PID == 1

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

 



https://bugzilla.kernel.org/show_bug.cgi?id=215769

--- Comment #1 from Alejandro Colomar (man-pages) (alx.manpages@xxxxxxxxx) ---
Hello Коренберг Марк,

On 3/29/22 13:02, bugzilla-daemon@xxxxxxxxxx wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=215769
> 
>             Bug ID: 215769
>            Summary: man 2 vfork() does not document corner case when PID
>                     == 1
>            Product: Documentation
>            Version: unspecified
>           Hardware: All
>                 OS: Linux
>             Status: NEW
>           Severity: normal
>           Priority: P1
>          Component: man-pages
>           Assignee: documentation_man-pages@xxxxxxxxxxxxxxxxxxxx
>           Reporter: socketpair@xxxxxxxxx
>         Regression: No
> 
> If a process has PID=1 (for example in pid namespace), calling vfork() always
> returns EINVAL. (https://bugs.python.org/issue47151).
> 
> Please add this informtion in "RETURN VALUE" section or just in somewhere
> else
> in the manpage.
> 
> Actually, it may be a bug in Linux kernel, I don't know. Possibly because the
> init process must not be suspended ?

Sorry, but I couldn't reproduce it.  Could you please run the following
test program in the same system that you're experiencing the bug?

I run it on Debian Sid with kernel 5.16 and glibc 2.33:

$ uname -a
Linux ADY-debian-11 5.16.0-5-amd64 #1 SMP PREEMPT Debian 5.16.14-1
(2022-03-15) x86_64 GNU/Linux
$ /lib/x86_64-linux-gnu/libc.so.6 | head -n1
GNU C Library (Debian GLIBC 2.33-7) release release version 2.33.



$ cat vfork.c
#define _GNU_SOURCE
#include <err.h>
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(void)
{
        pid_t pid;

        if (unshare(CLONE_NEWPID | CLONE_NEWNS) == -1)
                err(EXIT_FAILURE, "unshare(2)");
        if (signal(SIGCHLD, SIG_IGN) == SIG_ERR)
                err(EXIT_FAILURE, "sigaction(2)");
        pid = fork();
        switch (pid) {
        case 0:
                break;
        case -1:
                err(EXIT_FAILURE, "fork(2)");
        default:
                errx(EXIT_SUCCESS, "Parent exiting normally.");
        }
        if (getpid() != 1)
                errx(EXIT_FAILURE, "Child is not PID 1.");
        /* I'm not sure if I need to ignore it again, but just in case. */
        if (signal(SIGCHLD, SIG_IGN) == SIG_ERR)
                err(EXIT_FAILURE, "sigaction(2)");
        pid = vfork();
        switch (pid) {
        case 0:
                errx(EXIT_SUCCESS, "Grandchild exiting normally.");
        case -1:
                /* If we got here, the report is confirmed. */
                err(EXIT_FAILURE, "vfork(2)");
        default:
                errx(EXIT_SUCCESS, "Child exiting normally.");
        }
}
$ cc -Wall -Wextra vfork.c
$ sudo ./a.out
a.out: Parent exiting normally.
a.out: Grandchild exiting normally.
a.out: Child exiting normally.
$


If you can confirm the bug with this program, please send your system
details (most importantly, kernel and libc versions).


Thanks,

Alex

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.



[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