Skip to content

Commit 501a392

Browse files
committed
FIX: resolving last error id on posix platforms, if provided value to Make_OS-Error is zero (on Windows there is already used GetLastError in such a situation)
1 parent f422724 commit 501a392

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/core/f-stubs.c

+4
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,10 @@
864864
**
865865
*/ REBVAL *Make_OS_Error(int errnum)
866866
/*
867+
** Creates Rebol string from error number.
868+
** If errnum is zero, the number of last error will be resolved
869+
** using system functions.
870+
**
867871
***********************************************************************/
868872
{
869873
REBCHR str[100];

src/os/posix/host-lib.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ int pipe2(int pipefd[2], int flags); //to avoid "implicit-function-declaration"
420420
**
421421
***********************************************************************/
422422
{
423+
if (!errnum) errnum = errno;
423424
strerror_r(errnum, s_cast(str), len);
424425
return str;
425426
}
@@ -1280,9 +1281,14 @@ static int Try_Browser(char *browser, REBCHR *url)
12801281
exit(1);
12811282
break;
12821283
default:
1283-
waitpid(pid, &status, WUNTRACED);
1284-
result = WIFEXITED(status)
1284+
sleep(1); // needed else WEXITSTATUS sometimes reports value 127
1285+
if (0 > waitpid(pid, &status, WUNTRACED)) {
1286+
result = FALSE;
1287+
} else {
1288+
printf("status: %i WIFEXITED: %i WEXITSTATUS: %i\n", status, WIFEXITED(status), WEXITSTATUS(status) );
1289+
result = WIFEXITED(status)
12851290
&& (WEXITSTATUS(status) == 0);
1291+
}
12861292
}
12871293

12881294
return result;

0 commit comments

Comments
 (0)