Skip to content

Commit 1ee65d5

Browse files
authored
Add stub implementations of popen/pclose (#15013)
Fixes: emscripten-core/emsdk#890
1 parent 3ce1144 commit 1ee65d5

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

src/library.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ LibraryManager.library = {
183183
},
184184
vfork: 'fork',
185185
posix_spawn: 'fork',
186+
popen: 'fork',
187+
pclose: 'fork',
186188

187189
setgroups__deps: ['$setErrNo', 'sysconf'],
188190
setgroups__unimplemented: true,

tests/unistd/misc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ int main() {
129129
printf("vfork: %d", vfork());
130130
printf(", errno: %d\n", errno);
131131
errno = 0;
132+
printf("popen: %p", popen("/bin/ls", "r"));
133+
printf(", errno: %d\n", errno);
134+
errno = 0;
135+
printf("pclose: %d", pclose(NULL));
136+
printf(", errno: %d\n", errno);
137+
errno = 0;
132138

133139
printf("crypt: %s", crypt("foo", "bar"));
134140
printf(", errno: %d\n", errno);

tests/unistd/misc.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ fchown(good): 0, errno: 0
2727
fchown(bad): -1, errno: 8
2828
fork: -1, errno: 52
2929
vfork: -1, errno: 52
30+
popen: 0xffffffff, errno: 52
31+
pclose: -1, errno: 52
3032
crypt: ba4TuD1iozTxw, errno: 0
3133
encrypt, errno: 0
3234
getgid: 0, errno: 0

tools/system_libs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ def get_files(self):
721721
'res_query.c', 'res_querydomain.c', 'gai_strerror.c',
722722
'proto.c', 'gethostbyaddr.c', 'gethostbyaddr_r.c', 'gethostbyname.c',
723723
'gethostbyname2_r.c', 'gethostbyname_r.c', 'gethostbyname2.c',
724-
'alarm.c', 'syscall.c', 'popen.c',
724+
'alarm.c', 'syscall.c', 'popen.c', 'pclose.c',
725725
'getgrouplist.c', 'initgroups.c', 'wordexp.c', 'timer_create.c',
726726
'faccessat.c',
727727
# 'process' exclusion

0 commit comments

Comments
 (0)