NetBSD-Bugs archive

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

kern/41076: sigwaitinfo and sigtimedwait don't properly set siginfo

>Number:         41076
>Category:       kern
>Synopsis:       sigwaitinfo and sigtimedwait don't properly set siginfo
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 25 23:05:00 +0000 2009
>Originator:     Matteo Beccati
>Release:        4.0 (XEN DOM0)
NetBSD 4.0 NetBSD 4.0 (EPIA) #2: Sun Aug 10 00:15:28 CEST 

As far as I could see, sigtimedwait and sigwaitinfo only set si_signo and 
si_code. According to the manual, si_pid and si_uid should be set when si_code 
== SI_USER (== 0), and si_sigval should be set when si_code == SI_TIMER (== 
-2). That doesn't seem to happen.
user@epia:~$ cat sigwaitinfo.c
#include <stdio.h>
#include <signal.h>

int main(int argc, char **argv)
        pid_t pid = getpid();
        sigset_t mask;
        siginfo_t info;

        printf("Pid: %d\n", pid);

        sigaddset(&mask, SIGTERM);

        sigprocmask(SIG_BLOCK, &mask, NULL);

        kill(pid, SIGTERM);

        sigwaitinfo(&mask, &info);

        printf("Signal: %d, Code: %d, Pid: %d, Uid %d\n", info.si_signo, 
info.si_code, info.si_pid, info.si_uid);

        sigaddset(&mask, SIGALRM);

        sigprocmask(SIG_BLOCK, &mask, NULL);


        sigwaitinfo(&mask, &info);

        printf("Signal: %d, Code: %d, Sigval: %d\n", info.si_signo, 
info.si_code, info.si_sigval);

        return 0;
user@epia:~$ gcc sigwaitinfo.c
user@epia:~$ ./a.out
Pid: 19765
Signal: 15, Code: 0, Pid: 0, Uid 0
Signal: 14, Code: -2, Sigval: 0


Home | Main Index | Thread Index | Old Index