Nukesor / pueue

:stars: Manage your shell commands.
MIT License
4.69k stars 128 forks source link

Question: Is it possible for pueue to "adopt" a running process by PID? #461

Closed BatmanAoD closed 10 months ago

BatmanAoD commented 10 months ago

A detailed description of the feature you would like to see added.

(Sorry for submitting this question as a feature-request; I don't see a "discussion" page or anything like that. I don't know if this is a missing feature or something pueue is already capable of that I just don't see in the documentation. If it's not already implemented, then I'm guessing it's out-of-scope.)

Is it possible to give pueue control over a process that was started without pueue by telling it which PID to "adopt", or can pueue only manage processes that it starts?

Explain your usecase of the requested feature

Nushell currently has no support for background tasks, and pueue is an officially recommended tool for job control without built-in shell support.

However, there doesn't seem to be any way to turn a foreground process into a background job, which is a fairly common usage idiom on POSIX systems.

If Nushell had a way to suspend and disown processes, and pueue had a way to "adopt" them, that could effectively replace the typical use of the bg command in POSIX shells.

Alternatives

I think the only alternative would be to use a different tool: i.e. to find a process manager that can "adopt" suspended or running processes, or wait for Nushell to develop built-in process support (which will probably happen eventually anyway).

Additional context

No response

Nukesor commented 10 months ago

I didn't know that pueue is the officially recommended way to do background tasks for nushell :D

The problem is that pueue isn't designed to be a background process manager^^ It's rather a process manager for long running commands on servers or computation boxes, which are two, though similar in functionality, very different use cases.

I would actually suggest to use a different tool for background tasks. You might want to take a look at the Similar Project list. nq might provide the functionality you need.

TehPers commented 10 months ago

I think "officially recommended" might be a bit of an overstatement (that repository, from my understanding, is more of a community-maintained collection of helpful scripts), but it certainly fills a gap.

BatmanAoD commented 10 months ago

@TehPers It's also recommended in the Book: https://www.nushell.sh/book/background_task.html#using-nu-with-pueue

I agree that using pueue as a background task implementation is sub-optimal at best (and would be sub-optimal even if this feature existed).

TehPers commented 10 months ago

@TehPers It's also recommended in the Book: https://www.nushell.sh/book/background_task.html#using-nu-with-pueue

I agree that using pueue as a background task implementation is sub-optimal at best (and would be sub-optimal even if this feature existed).

I missed this, thanks for sharing!

Nukesor commented 10 months ago

Closing for now, since this is out of scope :)