-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
process: add execve #56496
process: add execve #56496
Conversation
Review requested:
|
What does it do on non-Unix systems? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #56496 +/- ##
=======================================
Coverage 90.21% 90.22%
=======================================
Files 630 629 -1
Lines 185213 185253 +40
Branches 36240 36230 -10
=======================================
+ Hits 167096 167143 +47
- Misses 11057 11068 +11
+ Partials 7060 7042 -18
🚀 New features to boost your workflow:
|
On Windows:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@ljharb I was totally wrong. Despite of naming and similar signatures, the function I'll disable this function on Windows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is to be added, I'd absolutely recommend referring to it by a standard name such as execve()
, or otherwise something that makes it clear that it spawns a new process.
This requires integration with the permissions API or is otherwise an immediate security hole.
Overall I'd recommend not adding this though, unless there's a concrete reason to believe that it fills a significant gap that the existing child_process
API doesn't cover.
Why would we want to add a function that can't work on all tier 1 platforms? |
Well, we already have a number of such apis... |
Gotcha, i wasn't aware of that. |
I don't consider it to be ideal. I would have preferred a pattern like |
+1 on @addaleax's alternative name suggestion. I'm fine with adding this so long as the cleanup logic/expectations are clearly documented. |
|
||
> Stability: 1 - Experimental | ||
|
||
* `file` {string} The name or path of the executable file to run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit... not in this PR but as a separate follow on we should likely align this with the fs module handling of paths so that file
can be represented using a Buffer
or URL
also.
Commit Queue failed- Loading data for nodejs/node/pull/56496 ✔ Done loading data for nodejs/node/pull/56496 ----------------------------------- PR info ------------------------------------ Title process: add execve (#56496) Author Paolo Insogna <[email protected]> (@ShogunPanda) Branch ShogunPanda:replace-process -> nodejs:main Labels c++, semver-minor, process, lib / src, tsc-agenda, needs-ci, commit-queue-squash Commits 4 - process: add execve - process: improvements - process: emit experimental warning when using execve - process: add execve to diagnostic_channel Committers 1 - Paolo Insogna <[email protected]> PR-URL: https://github.com/nodejs/node/pull/56496 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Bryan English <[email protected]> Reviewed-By: James M Snell <[email protected]> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/56496 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Bryan English <[email protected]> Reviewed-By: James M Snell <[email protected]> -------------------------------------------------------------------------------- ℹ This PR was created on Tue, 07 Jan 2025 06:26:52 GMT ✘ Requested Changes: 1 ✘ - Anna Henningsen (@addaleax): https://github.com/nodejs/node/pull/56496#pullrequestreview-2534964391 ✔ Approvals: 4 ✔ - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/56496#pullrequestreview-2533907058 ✔ - Rafael Gonzaga (@RafaelGSS) (TSC): https://github.com/nodejs/node/pull/56496#pullrequestreview-2679123979 ✔ - Bryan English (@bengl): https://github.com/nodejs/node/pull/56496#pullrequestreview-2703937360 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/56496#pullrequestreview-2703982184 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2025-03-13T15:48:57Z: https://ci.nodejs.org/job/node-test-pull-request/65720/ - Querying data for job/node-test-pull-request/65720/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/14000138702 |
PR-URL: #56496 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Bryan English <[email protected]> Reviewed-By: James M Snell <[email protected]>
Landed in 13a9d4c |
@addaleax The TSC has See: nodejs/TSC#1705. |
@ShogunPanda thats not a vote, it’s a motion. You should have dismissed the objection using GH UI and land the PR using the CQ (or manually, but only after the objection was dismissed). |
Thanks @aduh95, I keep forgetting about the difference. :) |
PR-URL: #56496 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Bryan English <[email protected]> Reviewed-By: James M Snell <[email protected]>
This PR adds a new
process.execve
method (absolutely willing to change the name if you want), which is a wrapper for theexecve
UNIX function.The function will never return and will swap the current process with a new one.
All memory and system resources are automatically collected from
execve
, except for std{in,out,err}.The primary use of this function is in shell scripts to allow to setup proper logics and then spawn another command.