nodejs / uvwasi

WASI syscall API built atop libuv
MIT License
226 stars 50 forks source link

Windows application without console has not stdin、stdout、stderr #157

Closed bxkai closed 1 year ago

bxkai commented 3 years ago

hi, uvwasi requires three file descriptors to startup -- 0, 1, and 2(stdin、stdout、stderr). Windows application without console has not stdin、stdout、stderr, I can open three files instead of them, but I don’t want to do this, is there any other solution? Thanks

Paril commented 3 years ago

Running into this issue, too. I'm loading as a DLL from an EXE, and there are no stdin/out/err descriptors, so uvwasi hard-fails by them stat'ing as UVWASI_FILETYPE_UNKNOWN (UV_EBADF).

Paril commented 3 years ago

windows_std.zip

For those coming across this, here's a small patch to work around the issue by inserting an "invalid" stream in the place of the stdio streams if they fail loading on Windows. I don't think this is the proper approach, I don't know what will happen if somebody attempts to read/write to them (I'd hope they just get voided), but it works well enough for me for now

cjihrig commented 2 years ago

@Paril would you be willing to share your patch as something other than a zip file?