Closed nrser closed 10 months ago
I think the ask here is more about exec as a function than can be used to replace the current process, like exec
in the shell, rather then spawn a subprocess. This works on most systems besides windows, and is not unreasonable.
There was discussion on matrix, the link in the original comment is perhaps a mistake?
For reference, here is some previous related discussion. Perhaps that was the intended link in the original post (^^;
I had already been working on os/posix-fork
this weekend, and just finished an implementation os/posix-exec
.
As noted though, these are not totally portable and will never exist on windows. There may also be other systems that cannot support them. Current implementation just checks #ifndef JANET_WINDOWS
, but perhaps we should put them behind a configuration flag
Request to add support for exec(3) family of functions.
Filed in response to the discussion at
https://www.man7.org/linux/man-pages/man3/exec.3.html
Thoughts & Notes
As a user it would be great if the implementation mirrored os/execute for simplicity and ease of recall, choosing which of the
exec
family (execl
,execlp
, ...,execvpe
) to invoke "under the hood" based on the provided options.I'm always found it tiring and error-prone how Python for example exposes each of the
exec
family directly, opposed to say Ruby which exposes a single method that makes the common, Bash-like use case easy.