Skip to content

Commit 251caf8

Browse files
committed
wasi: add a workaround for issues with shared open files
1 parent 35781cb commit 251caf8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/wasi.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3065,9 +3065,21 @@ wasi_instance_create(struct wasi_instance **instp) NO_THREAD_SAFETY_ANALYSIS
30653065
*
30663066
* XXX should restore on failure
30673067
* XXX should restore when we are done
3068+
* XXX this affects other programs sharing files.
3069+
* (eg. shell pipelines)
30683070
*/
30693071
uint32_t i;
30703072
for (i = 0; i < nfds; i++) {
3073+
if (isatty(i)) {
3074+
/*
3075+
* a fragile hack:
3076+
*
3077+
* tty is often shared with other processes.
3078+
* making such files non blocking breaks other
3079+
* processes.
3080+
*/
3081+
continue;
3082+
}
30713083
ret = set_nonblocking(i, true, NULL);
30723084
if (ret != 0) {
30733085
goto fail;

0 commit comments

Comments
 (0)