-
Notifications
You must be signed in to change notification settings - Fork 135
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
Ability to obtain current root process ID for a task #540
Comments
Good points, that feature request sounds pretty reasonable. It's definitely possible to do, however a few things need to be done first. Specifically #548, otherwise the message handlers won't have access to the process handles. Once the refactoring has taken place, the next steps are rather straight forward.
Some shells start futher subprocesses, some don't. It's basically up to the shell. Due to these reasons and the sake of maintainability, I would strongly prefer to not do any shell specific shenannigans to determine the first process that's not a shell, as this is very error prone and it's easy to run into race conditions (e.g. looking up a subprocess when the parent just finished and is destroyed). |
I finished the refactor in #547. |
Anyhow, I would really like to get some feedback on my previous message regarding the design of the actual requested feature. Is the feature even of any use to you, if you cannot tell whether you got a pid of a shell or a shell's subprocess? |
Ping @vvuk |
Yep, will take a look today! Was out most of last week :) |
Whoops I missed the question, sorry -- got this confused with another notification.
Yep! I can take that into account, and for the most part it's manual usage when I'd want the pid (e.g. the debugger attach case). I can take care to only launch things that won't create subshells or just deal with it; either way there would be a human in the loop vs. something automated being surprised to discover a shell/not-shell. |
Oh I didn't get it confused -- is the stack overflow issue still there? Happy to take a look and see if I can help. |
Thanks, I got the stack overflow issue fixed. It was a bad case of recursion accross 4 corners :D So, I'm wondering how to best implement this. By default, it would just print some info in a nice human-readable way. Something like:
Would that work for you? You could then just extract the pid via |
Ping @vvuk |
I'd love to see a general |
Wouldn't just adding process PID to the output of As nushell user myself, this would even be preferable, as |
@j-xella The reason why I don't like that approach is that this would require the Alternatively, a new I'll think about this some more and check whether that's still the best way to do things. |
A detailed description of the feature you would like to see added.
This was mentioned in #364 which was closed because the original issue author stopped needing it. I came to
pueue
vianushell
, where it's a suggested way to work aroundnushell
's lack of process management. And for the most part it's great, and far better than bash/zsh process management. However, I frequently just need the process ID of the background process I spawned.I understand this isn't always a simple thing to provide; however, ultimately, there is a process that the pueue daemon launches for a task. That might be a shell if shell execute is used -- which I understand is supposed to be always, but it seems like this is skipped in some instances. When launching an app, I see the app process as a child of the daemon, without a shell in between. But either way, I'd like to easily obtain the process ID of whatever the thing is that the daemon launched, even if it's the shell. (Indeed I just tested -- if I include shell special characters like
>
then sh is launched)Explain your usecase of the requested feature
Using pueue as a general rich background task manager. Sometimes the process ID is needed -- attaching a debugger/profiler, for example. It would be very convenient if this was easily available.
Alternatives
ps -ef | grep
and then hunt for the process you want. Doable, but not pleasant.Additional context
No response
The text was updated successfully, but these errors were encountered: