Skip to content

Commit

Permalink
FIX: resolving last error id on posix platforms, if provided value to…
Browse files Browse the repository at this point in the history
… Make_OS-Error is zero (on Windows there is already used GetLastError in such a situation)
  • Loading branch information
Oldes committed Jan 2, 2019
1 parent f422724 commit 501a392
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/core/f-stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,10 @@
**
*/ REBVAL *Make_OS_Error(int errnum)
/*
** Creates Rebol string from error number.
** If errnum is zero, the number of last error will be resolved
** using system functions.
**
***********************************************************************/
{
REBCHR str[100];
Expand Down
10 changes: 8 additions & 2 deletions src/os/posix/host-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ int pipe2(int pipefd[2], int flags); //to avoid "implicit-function-declaration"
**
***********************************************************************/
{
if (!errnum) errnum = errno;
strerror_r(errnum, s_cast(str), len);
return str;
}
Expand Down Expand Up @@ -1280,9 +1281,14 @@ static int Try_Browser(char *browser, REBCHR *url)
exit(1);
break;
default:
waitpid(pid, &status, WUNTRACED);
result = WIFEXITED(status)
sleep(1); // needed else WEXITSTATUS sometimes reports value 127
if (0 > waitpid(pid, &status, WUNTRACED)) {
result = FALSE;
} else {
printf("status: %i WIFEXITED: %i WEXITSTATUS: %i\n", status, WIFEXITED(status), WEXITSTATUS(status) );
result = WIFEXITED(status)
&& (WEXITSTATUS(status) == 0);
}
}

return result;
Expand Down

0 comments on commit 501a392

Please sign in to comment.