-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
child_process: Add child_processes.isRootProcess flag #16258
Comments
Why put it in |
I don't see the usefulness in adding this when you can just do |
I'm -1 on this. You should be able to check for |
Readability is a good reason to add this. It's much clearer what |
We have cluster.isMaster and cluster.isWorker and this feature request is along the same lines. This is about providing readability into child_process as stated by @sindresorhus. I had to discover that I could do |
I also had no idea you could check |
Maybe a tip in the documentation would suffice? |
That doesn't really solve the readability concern though. |
For background: when That rationale doesn't apply here. Aside: |
Welcome @arei, and thanks for the feedback. Based on the above comments I think it's a bit complicated to achieve. AFAICT a |
@bnoordhuis don’t disagree that the name could be better. |
I run into this problem once, and having to discover about the Would an API like |
I'm not seeing much movement but more importantly, the request basically seems to be for an alias of Unless someone has a proposal on how to proceed in the next few days, I'm going to close this out. |
I would be disappointed if this was closed. This absolutely boils down to a more succinct, documented approach to finding out if there is a parent node process or not. Yes, there is a way to do this already, but it is not clearly expressed. This feature request aims to solve that. And shouldn’t we be striving to make node more clearly express its intents? |
There's no point to keeping issues open that are stale unless there's a clear path forward or there's great demand (with no dissent). Right now neither of those is true. Issues were brought up, e.g.
and have not been addressed. As it is, we can't even put a label on this such as "help wanted" or "good first issue" because there's no path forward. As @refack mentioned, if someone wants to open a PR or move this conversation forward then great but in the absence of that it just makes it really hard to manage the issue tracker. |
Here's my proposed solution... Any time a Add a function to Thus all downstream spawned processes will return I will submit a PR if I can ever get the project to build and test under windows. |
process.isTopLevelNodeProcess() will return true if the current process was not originated by fork, spawn, or other like node execution. Otherwise it will return false. Fixes: nodejs#16258
Given the consensus is that this is not really a problem worth solving, I am closing it. I have also implemented this out in userland, although it is far from pretty. I mention it here for others whom may have the same problem or if anyone is interested in seeing: https://www.npmjs.com/package/toplevelprocess |
This is a new feature request to add a flag (boolean) to child_process, called something along the lines of
child_process.isRootProcess
that would return true if the current process is the "root" of the child_process.fork tree or false if the current process was a forked process and has an upstream ipc channel.In essence this is a simple one-liner inside of child_process:
or something similar.
The text was updated successfully, but these errors were encountered: