Skip to content
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

Would using one-step posix_spawn instead of two-step fork–exec enable an image-only FFI solution? #2

Open
jeremy-w opened this issue Mar 15, 2018 · 2 comments

Comments

@jeremy-w
Copy link

The README says there's a problem where GC and such can occur between the fork and exec calls, when they are made via FFI.

There is a newer (2010-ish) POSIX API that supports one-step process creation: posix_spawn. For rigging up stream redirections (stdin, stdout, etc), it supports passing in a set of file actions to be run before starting the child process.

This might be enough to let you successfully spawn a subprocess using a single FFI call.

@guillep
Copy link
Collaborator

guillep commented Mar 15, 2018

We have seen the usage of posix_spawn in OSSubprocess already.

However, the thing are not the file redirections but starting the tty session, that requires some function calls before exec'ing.

If there is a full in-image solution that would be great though

@Rinzwind
Copy link

Rinzwind commented Feb 7, 2024

It’s been a few years since this issue was opened, but if you’re still interested you can take a look at PTerm pull request #54 in which the implementation was changed to always use posix_spawn. Previously, posix_spawn was only used as a fallback when PTerm could not compile or load its own function pterm_spawn_tty. An issue due to that change that’s still open however is that the controlling terminal of the new process is no longer set, see PTerm issue #58 for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants