mirror of
https://github.com/python/cpython.git
synced 2025-10-30 13:11:29 +00:00
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
This commit is contained in:
parent
aafbdb5df5
commit
12d2f373b9
1 changed files with 6 additions and 2 deletions
|
|
@ -1,6 +1,10 @@
|
||||||
#include "emscripten.h"
|
#include "emscripten.h"
|
||||||
#include "stdio.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
|
// 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
|
// 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.
|
// 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) {
|
||||||
int flags = fcntl(fd, F_GETFL, 0);
|
int flags = fcntl(fd, F_GETFL, 0);
|
||||||
int nonblock = **((int**)varargs);
|
int nonblock = **((int**)varargs);
|
||||||
if (flags < 0) {
|
if (flags < 0) {
|
||||||
return errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
if (nonblock) {
|
if (nonblock) {
|
||||||
flags |= O_NONBLOCK;
|
flags |= O_NONBLOCK;
|
||||||
|
|
@ -311,7 +315,7 @@ int __syscall_ioctl(int fd, int request, void* varargs) {
|
||||||
}
|
}
|
||||||
int res = fcntl(fd, F_SETFL, flags);
|
int res = fcntl(fd, F_SETFL, flags);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
return errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue