Skip to content

Commit

Permalink
(engine) fix prolog_wait for win32
Browse files Browse the repository at this point in the history
Src-commit: 7d16309d0f66cf66d2ff20941709ae13b66387f1
  • Loading branch information
jfmc committed Jul 22, 2024
1 parent 4c922d2 commit a8dd05e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/engine/io_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1780,7 +1780,7 @@ CBOOL__PROTO(prolog_set_unbuf) {
CBOOL__PROTO(prolog_input_wait) {
ERR__FUNCTOR("io_basic:$input_wait", 3);
#if defined(_WIN32) || defined(_WIN64) /* MinGW */
#warning "io_basic:$input_wait is not supported in the Win32 build" /* TODO:[JF] fixme */
#warning "TODO(MinGW): we need select() in io_basic:$input_wait"
CBOOL__PROCEED;
#else
int errcode;
Expand Down
9 changes: 9 additions & 0 deletions core/engine/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -2153,6 +2153,14 @@ CBOOL__PROTO(prolog_wait) {
}

int retcode;
#if defined(_WIN32) || defined(_WIN64)
// Windows-specific process termination handling
if (status & 0xC0000000) { /* error */
retcode = -(status & 0xC0000000); /* negative number for signals */
} else {
retcode = status; /* Process terminated normally */
}
#else
/* Process did not terminated normally */
if (WIFSIGNALED(status)) { /* Process terminated due to signal */
retcode = -WTERMSIG(status); /* negative number for signals */
Expand All @@ -2162,6 +2170,7 @@ CBOOL__PROTO(prolog_wait) {
// TODO: only if WIFSTOPPED(status) (see man page)
return FALSE;
}
#endif
CBOOL__LASTUNIFY(X(1), MakeSmall(retcode));
}

Expand Down

0 comments on commit a8dd05e

Please sign in to comment.