1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-02-01 06:12:31 +00:00

Use waitpid, not wait3, etc. (#44)

This removes code that uses `union wait` status in favor of code
that uses `int` status. This has been the correct way since
SvR4, BSD 4.3, POSIX.
This commit is contained in:
Bruce Mitchener
2020-12-15 00:58:28 +07:00
committed by GitHub
parent 20040a73b0
commit 9c01d39812
3 changed files with 3 additions and 31 deletions

View File

@@ -479,47 +479,26 @@ int fork_Unix() {
case 'W': /* Wait for a process to die. */
{
#if defined(SYSVONLY) || defined(WAITINT)
int status;
#else
union wait status;
#endif /* SYSVONLY */
#ifdef OCR
int slot;
#endif
#if defined(SYSVONLY) || defined(WAITINT)
status = 0;
#else
status.w_status = 0;
#endif /* SYSVONLY */
IOBuf[0] = 0;
IOBuf[1] = 0;
DBPRINT(("About to wait for processes.\n"));
#ifdef SYSVONLY
retry1:
pid = waitpid(-1, &status, WNOHANG);
if (pid == -1 && errno == EINTR) goto retry1;
#else
pid = wait3(&status, WNOHANG, 0);
#endif /* SYSVONLY */
if (pid > 0)
{
/* Ignore processes which are suspended but haven't exited
(this shouldn't happen) */
#if defined(SYSVONLY) || defined(WAITINT)
if (pid > 0) {
/* Ignore processes which are suspended but haven't exited
(this shouldn't happen) */
if (WIFSTOPPED(status)) break;
IOBuf[3] = status >> 8;
IOBuf[2] = status & 0xFF;
#else
if (status.w_stopval == WSTOPPED) break;
IOBuf[3] = status.w_T.w_Retcode;
IOBuf[2] = status.w_T.w_Termsig;
#endif /* SYSVONLY */
IOBuf[1] = pid & 0xFF;
IOBuf[0] = (pid >> 8) & 0xFF;
}