Skip to content

Commit

Permalink
Use waitpid, not wait3, etc. (#44)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
waywardmonkeys committed Dec 14, 2020
1 parent 20040a7 commit 9c01d39
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 31 deletions.
2 changes: 0 additions & 2 deletions inc/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ typedef signed char s_char;
#undef HAS_GETHOSTID
#define BSD_COMP 1
#define SYSVSIGNALS 1
#define WAITINT 1
#define L_SET SEEK_SET
#define NOFORN
#define LOCK_X_UPDATES 1
Expand Down Expand Up @@ -297,7 +296,6 @@ typedef signed char s_char;
/* MacOS X, FreeBSD - mostly POSIX-compliant Unix */
#define NOETHER 1
#define XWINDOWS 1
#define WAITINT 1

#undef REGISTER
#define REGISTER
Expand Down
27 changes: 3 additions & 24 deletions src/unixfork.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 0 additions & 5 deletions src/uraid.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,7 @@ LispPTR uraid_commands() {
LispPTR index;
DefCell *defcell68k;
#ifndef DOS
#if defined(SYSVONLY) || defined(WAITINT)
int status;
#else
union wait status;
#endif /* SYSVONLY */

#endif /* DOS */

if (URaid_argnum == -1) {
Expand Down

0 comments on commit 9c01d39

Please sign in to comment.