-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Questions regarding MemoryFileSystem and Stdio #143
Comments
Also I noticed that the behavior of
|
Same issue here. Can't find examples or tests that shows how to use that. ping @dbaeumer |
@adrienaury sorry for the late reply. But I totally overlooked the issue. Regarding EOF. This is currently not handled correct in the streams implementation (see https://github.com/microsoft/vscode-wasi/blob/main/wasm-wasi-core/src/common/streams.ts#L68) What I can do to mimic an OS implementation is to return a Uint8Array of length zero if the implementation detects Has any of you tested how this behaves on another WASI compliant runtime like wasmtime? |
I think checking if any chunk ends with 0x04 (End of Transmission) is a good way to indicate the stdin stream end for vscode-wasm. About wasmtime: Running with wasmtime by piping the file to stdin works and
Here is how the file/stdin is read: fn fd_read_all(fd: u32) -> Result<Vec<u8>, String> {
let mut output = Vec::<u8>::new();
let mut chunk = [0; 256];
let in_vec = [wasi::Iovec {
buf: chunk.as_mut_ptr(),
buf_len: chunk.len(),
}];
loop {
let nread = match unsafe { wasi::fd_read(fd, &in_vec) } {
Ok(nread) => nread,
Err(err) => {
// stdin is empty
if fd == 0 && err == wasi::ERRNO_AGAIN {
break;
}
return Err(alloc::format!("Error reading file: fd={fd}, err={err}\n"));
}
};
if nread == 0 {
break;
}
output.extend(&chunk[0..nread]);
}
Ok(output)
} |
I added EOT support but I can't do that in a transparent way. EOT (end of transmission) is a terminal feature and not a general stream feature. So if you want a writable with EOT support you need to create it special using wasm.createWritable({ eot: true, encoding: ... }); |
You can also create a normal stream using Both will be available in a new version of the extension. |
In a typical UNIX system, the behavior we see after pressing I think that it is the pseudo-terminal (PTY) that should provide the capability to capture and handle common shortcuts. VS Code does not emulate a shell process for the PTY, so it is reasonable that |
I just came across this PR: 6af74e0. This was exactly the approach I just have proposed. Looking forward to seeing that roll out soon! |
Hi,
First of all thank you for this extension, this is a great job!
I have few questions regarding MemoryFileSystem and Stdio.
First here is my current code i'm trying to get worked.
My questions are :
1 - the process reads an input of type
pipeIn
created with awasm.createWritable()
call, but it does not seem to catch the EOF and hang indefinitly waiting for more bytes. How can I indicates to the process that there nothing more and it should end ?2 - at some point, the process reads a file
/memory/masking.yml
that is created by a call tofs.createFile("masking.yml", ...)
, the file exist I can get a stat (it is a regular file) but the process get an error Errno.perm ("Operation is not permitted") when trying to read it (call topath_open
). Is it something I'm doing wrong ? or maybe the wasm file is not correct (i use the go compiler 1.21)Thank you in advance ! Any help appreciated
The text was updated successfully, but these errors were encountered: