Proper behaviour for wait()?

From: Paul Herman (pherman_at_frenchfries.net)
Date: 05/31/03

  • Next message: M. Warner Losh: "Re: gcc bug? Openoffice port impossibel to compile on 4.8"
    Date: Fri, 30 May 2003 22:00:18 -0700 (PDT)
    To: hackers@freebsd.org
    
    

    Just curious,

    anyone know what the "proper" behavior for wait() is when SIGCHLD
    is ignored? Is it simply undefined? Don't see anything mentioned
    in the wait(2) manpage one way or tother, and other OSes don't seem
    to agree much.

    -Paul.

    bash$ cat wait.c
    #include <sys/types.h>
    #include <sys/wait.h>
    #include <signal.h>
    #include <stdio.h>
    #include <unistd.h>

    int main() {
            int status;
            pid_t pid = fork();

            if (!pid) { sleep(1); _exit(0); }

            signal(SIGCHLD, SIG_IGN);
            printf("waitpid() = %d\n", waitpid(pid, &status, 0));
            signal(SIGCHLD, SIG_DFL);
            return 0;
    }
    bash$ cc wait.c

    [FreeBSD 4.8]
    bash$ ./a.out
    waitpid() = 7553
    bash$

    [Linux 2.4.21]
    bash$ ./a.out
    waitpid() = 24536
    bash$

    [Darwin 6.6]
    bash$ ./a.out
    waitpid() = -1
    bash$

    [Solaris 8]
    bash$ ./a.out
    waitpid() = -1
    bash$

    [OpenBSD 3.3]
    bash$ ./a.out
    ...just hangs...

    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


  • Next message: M. Warner Losh: "Re: gcc bug? Openoffice port impossibel to compile on 4.8"

    Relevant Pages