[comp.unix.ultrix] DECstation 'waitpid

mcm@rti.rti.org (Mike Mitchell) (09/08/90)

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@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."

alan@shodha.enet.dec.com ( Alan's Home for Wayward Notes File.) (09/08/90)

In article <4054@rtifs1.UUCP>, mcm@rti.rti.org (Mike Mitchell) writes:
} 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:
} 
} [ Example program given. ]
} 
} 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.
}
	If I manage to find the I'll test the program on one or
	more of my V4 systems and will try to submit an internal
	problem report.  You should submit the test problem and
	appropriate as an SPR.  There's at least one copy of the
	form included in with the documentation.

	Yes, I wish you could do this electronically too, but at
	moment that's not the way the "system" works.  If you have
	a support contract you might be able to get the CSC to
	help report it.
	 
} 
} Mike Mitchell	{decvax,seismo,ihnp4,philabs}!mcnc!rti!mcm  mcm@rti.rti.org
} 
-- 
Alan Rollow				alan@nabeth.enet.dec.com