Skip to content

[PHP.wasm] Support non-blocking read streams #2328

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

Closed
wants to merge 10 commits into from

Conversation

adamziel
Copy link
Collaborator

@adamziel adamziel commented Jul 5, 2025

Motivation for the change, related issues

Description TBD.

With this PR, we can use the Symfony Process component. It spawns a new process via proc_open(), marks its output stream as non-blocking, and immediately reads the initial output bytes if any are present. Before this change, Playground would block until the first output is produced, and, sometimes until the entire process finishes.

Implementation details

Testing Instructions (or ideally a Blueprint)

@@ -344,6 +344,8 @@ EM_JS(__wasi_errno_t, js_fd_read, (__wasi_fd_t fd, const __wasi_iovec_t *iov, si
}

const success = returnCode === 0;
// @TODO: Do not reason about child_proc_by_fd. Just use pipes and detect
Copy link
Collaborator Author

@adamziel adamziel Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, PHP uses that distinction internally, so maybe it's not a problem at all? Although we operate at the kernel level here.

https://github.com/php/php-src/blob/004cb827501d1ddaf98daacb185a53e0816f78a7/main/streams/plain_wrapper.c#L476

if (data->is_process_pipe) {
	errno = 0;
	ret = pclose(data->file);

#if HAVE_SYS_WAIT_H
	if (WIFEXITED(ret)) {
		ret = WEXITSTATUS(ret);
	}
#endif
} else {
	ret = fclose(data->file);
	data->file = NULL;
}

@adamziel
Copy link
Collaborator Author

superseded by #2339

@adamziel adamziel closed this Jul 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant