Re: waitid() return value strangeness when infop is NULL

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

 



Test program below.  Two test runs, of which the second shows the
behavior I'm reporting.

$ ./a.out
Created child with PID 7727
infop = 0xbfe608e0
waitid() returned 0
$ ./a.out n
Created child with PID 7729
infop = (nil)
waitid() returned 7729

===

#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <signal.h>
#include <unistd.h>

int
main(int argc, char *argv[])
{
    siginfo_t info, *infop;
    int options, idtype;
    long s;
    pid_t child;

    child = fork();
    if (child == 0)
        exit(0);
    printf("Created child with PID %ld\n", (long) child);

    idtype = P_PID;
    options = WEXITED;
    infop = (argc > 1 && strchr(argv[1], 'n') != NULL) ? NULL : &info;

    printf("infop = %p\n", infop);

    s = syscall(SYS_waitid, idtype, child, infop, options, NULL);
    if (s == -1) {
        perror("waitid");
        exit(EXIT_FAILURE);
    }

    printf("waitid() returned %ld\n", s);

    exit(EXIT_SUCCESS);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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