DECstation 'waitpid()' broken

Mike Mitchell mcm at rti.rti.org
Sat Sep 8 05:15:40 AEST 1990


There is a bug in the implementation of the 'waitpid()' system call on
the DECstations.  This applies to all DECstation versions of ULTRIX with
the'waitpid' system call, including ULTRIX 4.0.  The bug is that the
kernel does not return ANY status information.  You can pass in a 
'union status' to the waitpid system call, but the kernel does not
modify the union.  To prove it, try running the following program:

=======================================================================

#include <sys/wait.h>

#define	CHILDEXIT	0

main()
{
    int pid;
    union wait status;

    if ((pid = fork()) == 0)
	exit(CHILDEXIT);

    WEXITSTATUS(status) = 111;
    waitpid(pid, &status, 0);
    printf("child exited with status %d (waitpid)\n", WEXITSTATUS(status));
    if (WEXITSTATUS(status) != CHILDEXIT)
	printf("Your implementation of 'waitpid()' is broken!!!\n");


    if ((pid = fork()) == 0)
	exit(CHILDEXIT);

    WEXITSTATUS(status) = 111;
    wait3(&status, 0, 0);
    printf("\nchild exited with status %d (wait3)\n", WEXITSTATUS(status));
    if (WEXITSTATUS(status) != CHILDEXIT)
	printf("Your implementation of 'wait3()' is broken!!!\n");


    if ((pid = fork()) == 0)
	exit(CHILDEXIT);

    WEXITSTATUS(status) = 111;
    wait(&status);
    printf("\nchild exited with status %d (wait)\n", WEXITSTATUS(status));
    if (WEXITSTATUS(status) != CHILDEXIT)
	printf("Your implementation of 'wait()' is broken!!!\n");
}

=========================================================================

Notice that the 'wait3()' and 'wait()' system calls work fine, but the
new 'waitpid()' system call is broken.

This bug does NOT appear on the VAX version of ULTRIX.  I thought the
systems were built from common source, and were "bug-for-bug compatible".
>From looking at the proliferation of '#ifdef vax' and '#ifdef mips' in
the include files, they might be built from the same source files, but
obviously not the same source code.

Anyway, the waitpid system call is broken on all versions of ULTRIX on
DECstations, and should not be used if you are interested in the exit
status of the children.


Mike Mitchell	{decvax,seismo,ihnp4,philabs}!mcnc!rti!mcm  mcm at rti.rti.org

"There's laughter where I used to see a tear.		    (919) 541-6098
 It's all done with mirrors, have no fear."



More information about the Comp.unix.ultrix mailing list