mirror of https://github.com/pyodide/pyodide.git
76 lines
2.9 KiB
Diff
76 lines
2.9 KiB
Diff
![]() |
From 52c0b163bad96cde2081c734680b9ec485fea908 Mon Sep 17 00:00:00 2001
|
||
|
From: Hood <hood@mit.edu>
|
||
|
Date: Wed, 8 Sep 2021 17:49:15 -0700
|
||
|
Subject: [PATCH] Fix dup
|
||
|
|
||
|
---
|
||
|
src/library_syscall.js | 12 ++++++------
|
||
|
tests/third_party/posixtestsuite | 2 +-
|
||
|
2 files changed, 7 insertions(+), 7 deletions(-)
|
||
|
|
||
|
This should fix two problems with the `dup` system calls:
|
||
|
1. Pipes cannot be duplicated (https://github.com/emscripten-core/emscripten/issues/14640)
|
||
|
2. `TemporaryFiles` cannot be duplicated (https://github.com/emscripten-core/emscripten/issues/15012)
|
||
|
|
||
|
Both of these issues cause trouble with pytest. There is an upstream pull request that would fix this problem:
|
||
|
https://github.com/emscripten-core/emscripten/pull/9396/files
|
||
|
|
||
|
This patch only partially resolves the problems with `dup` (it doesn't fully duplicate the changes in the emscripten PR) but I think it will be good enough to fix pytest.
|
||
|
|
||
|
diff --git a/emsdk/upstream/emscripten/src/library_syscall.js b/emsdk/upstream/emscripten/src/library_syscall.js
|
||
|
index 96d2ec0c3..0001624ec 100644
|
||
|
--- a/emsdk/upstream/emscripten/src/library_syscall.js
|
||
|
+++ b/emsdk/upstream/emscripten/src/library_syscall.js
|
||
|
@@ -137,10 +137,10 @@ var SyscallsLibrary = {
|
||
|
}
|
||
|
return 0;
|
||
|
},
|
||
|
- doDup: function(path, flags, suggestFD) {
|
||
|
+ doDup: function(stream, suggestFD) {
|
||
|
var suggest = FS.getStream(suggestFD);
|
||
|
if (suggest) FS.close(suggest);
|
||
|
- return FS.open(path, flags, 0, suggestFD, suggestFD).fd;
|
||
|
+ return FS.createStream(stream, suggestFD, suggestFD).fd;
|
||
|
},
|
||
|
doReadv: function(stream, iov, iovcnt, offset) {
|
||
|
var ret = 0;
|
||
|
@@ -380,7 +380,7 @@ var SyscallsLibrary = {
|
||
|
},
|
||
|
__sys_dup: function(fd) {
|
||
|
var old = SYSCALLS.getStreamFromFD(fd);
|
||
|
- return FS.open(old.path, old.flags, 0).fd;
|
||
|
+ return FS.createStream(old, 0).fd;
|
||
|
},
|
||
|
__sys_pipe__deps: ['$PIPEFS'],
|
||
|
__sys_pipe: function(fdPtr) {
|
||
|
@@ -472,7 +472,7 @@ var SyscallsLibrary = {
|
||
|
__sys_dup2: function(oldfd, suggestFD) {
|
||
|
var old = SYSCALLS.getStreamFromFD(oldfd);
|
||
|
if (old.fd === suggestFD) return suggestFD;
|
||
|
- return SYSCALLS.doDup(old.path, old.flags, suggestFD);
|
||
|
+ return SYSCALLS.doDup(old, suggestFD);
|
||
|
},
|
||
|
__sys_getppid__nothrow: true,
|
||
|
__sys_getppid__proxy: false,
|
||
|
@@ -1167,7 +1167,7 @@ var SyscallsLibrary = {
|
||
|
return -{{{ cDefine('EINVAL') }}};
|
||
|
}
|
||
|
var newStream;
|
||
|
- newStream = FS.open(stream.path, stream.flags, 0, arg);
|
||
|
+ newStream = FS.createStream(stream, arg);
|
||
|
return newStream.fd;
|
||
|
}
|
||
|
case {{{ cDefine('F_GETFD') }}}:
|
||
|
@@ -1403,7 +1403,7 @@ var SyscallsLibrary = {
|
||
|
assert(!flags);
|
||
|
#endif
|
||
|
if (old.fd === suggestFD) return -{{{ cDefine('EINVAL') }}};
|
||
|
- return SYSCALLS.doDup(old.path, old.flags, suggestFD);
|
||
|
+ return SYSCALLS.doDup(old, suggestFD);
|
||
|
},
|
||
|
__sys_pipe2__nothrow: true,
|
||
|
__sys_pipe2__proxy: false,
|
||
|
--
|
||
|
2.17.1
|
||
|
|