From 9dad34c7673a3bb0db7c97c42148c53e3121a24b Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Tue, 22 Jul 2025 14:28:46 +0200 Subject: [PATCH 1/2] gh-124621: Emscripten: Fix __syscall_ioctl patch If there is an error, we have to return `-errno` not positive errno. Included in backport of GH-136931: #136988 --- Python/emscripten_syscalls.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Python/emscripten_syscalls.c b/Python/emscripten_syscalls.c index 404d98d492a655..b1236e6b123fc9 100644 --- a/Python/emscripten_syscalls.c +++ b/Python/emscripten_syscalls.c @@ -302,7 +302,7 @@ int __syscall_ioctl(int fd, int request, void* varargs) { int flags = fcntl(fd, F_GETFL, 0); int nonblock = **((int**)varargs); if (flags < 0) { - return errno; + return -errno; } if (nonblock) { flags |= O_NONBLOCK; @@ -311,7 +311,7 @@ int __syscall_ioctl(int fd, int request, void* varargs) { } int res = fcntl(fd, F_SETFL, flags); if (res < 0) { - return errno; + return -errno; } return res; } From 796a446f885e79461abaa40ae68fa1046a98de01 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Tue, 22 Jul 2025 14:37:04 +0200 Subject: [PATCH 2/2] Add comment about return value --- Python/emscripten_syscalls.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Python/emscripten_syscalls.c b/Python/emscripten_syscalls.c index b1236e6b123fc9..98ee44276e53e0 100644 --- a/Python/emscripten_syscalls.c +++ b/Python/emscripten_syscalls.c @@ -1,6 +1,10 @@ #include "emscripten.h" #include "stdio.h" +// All system calls: return nonnegative number on success, return -errno on +// failure. Negative results get stored back into errno here: +// https://github.com/emscripten-core/emscripten/blob/main/system/lib/libc/musl/src/internal/syscall_ret.c#L7 + // If we're running in node, report the UID of the user in the native system as // the UID of the user. Since the nodefs will report the uid correctly, if we // don't make getuid report it correctly too we'll see some permission errors. 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