lkml.org 
[lkml]   [2009]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: waitid() return value strangeness when infop is NULL
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);
}


\
 
 \ /
  Last update: 2009-01-13 23:45    [W:0.072 / U:1.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site