Skip to content

Commit 12d2f37

Browse files
authored
gh-124621: Emscripten: Fix __syscall_ioctl patch (GH-136993)
If there is an error, we have to return `-errno` not positive errno. Included in backport of GH-136931: #136988
1 parent aafbdb5 commit 12d2f37

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Python/emscripten_syscalls.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#include "emscripten.h"
22
#include "stdio.h"
33

4+
// All system calls: return nonnegative number on success, return -errno on
5+
// failure. Negative results get stored back into errno here:
6+
// https://github.com/emscripten-core/emscripten/blob/main/system/lib/libc/musl/src/internal/syscall_ret.c#L7
7+
48
// If we're running in node, report the UID of the user in the native system as
59
// the UID of the user. Since the nodefs will report the uid correctly, if we
610
// don't make getuid report it correctly too we'll see some permission errors.
@@ -302,7 +306,7 @@ int __syscall_ioctl(int fd, int request, void* varargs) {
302306
int flags = fcntl(fd, F_GETFL, 0);
303307
int nonblock = **((int**)varargs);
304308
if (flags < 0) {
305-
return errno;
309+
return -errno;
306310
}
307311
if (nonblock) {
308312
flags |= O_NONBLOCK;
@@ -311,7 +315,7 @@ int __syscall_ioctl(int fd, int request, void* varargs) {
311315
}
312316
int res = fcntl(fd, F_SETFL, flags);
313317
if (res < 0) {
314-
return errno;
318+
return -errno;
315319
}
316320
return res;
317321
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy