Repository navigation
Jobs - #14883
Jobs#14883
Conversation
|
looks interesting! by the way, if you haven't seen these PRs which also try to tackle background jobs, and might have some info on roadblocks you might run into. seems like the major blocker was the external printer in reedline. |
Yeah, the mentioned reedline output problems have already shown up. I'll have a look into it, thanks. |
This implementation still does not kill the job's current process if it is executing any, but already sends an interrupt through Signals which allows the job to be interrupted if it is running nushell code.
We still need to implement unfreezing it after suspending the program, and killing frozen jobs. TSTP a unix-specific thing, that could possibly be *emulated* in windows in the future, but for now, I think implementing this expected unix shell behaviour is a good call.
This solves an issue that jobs were being silenced even when piped into a Value, which is not desirable. This commit addresses and adds tests for this behavior.
|
Oh well, it seems there was a mistake in my implementation for slient background jobs. The intended output would be something lke this: Rationale: Even though background jobs are silenced on command output, an explicit Rationale: background job terminal output is silenced Same rationale as case 1. I pushed a fix and some tests to cover this behavior. |
|
Sorry, missed your earlier changes, looks good on my end. |
|
looks like we're good to go! thank you again so much for working on this, we're all eager to give it a shot 😄 |
|
@cosineblast Congrats on landing a PR that we've wanted for over 5 years now. Way to go! First question, is this a bug or intended behavior. On Windows, if I do |
|
Well, that's mostly intentional. Some GUI programs like firefox on linux and notepad on windows do not block the terminal (by spawning the actual graphical application in another child process). In that case, the job will terminate since the new process just terminated |
|
@cosineblast Thank you for implementing such amazing feature! |
|
You're welcome, I'm very glad to help. I plan on improving this feature in the future (e.g adding messaging, improving tests robustness, etc), but for the time being I think this is enough |
|
Thanks for all the work! I saw a test failure in |
I've seen the same intermittent test failure locally as well as in one other test. In both cases, it seemed to be a timing issue, and locally modifying the |
|
I'll experiment on improving them with some better inter-job communication mechanisms soon, thanks for pointing those issues out |
|
Are hotkeys/shortcuts going to be impl as well in the future? |
Do you have particular shortcuts in mind? Feel free to open an enhancement issue, we can put it under the job-control label |
Description
This is an attempt to improve the nushell situation with regard to issue #247.
This PR implements:
spawning jobs:
job spawn { do_background_thing }Jobs will be implemented as threads and not forks, to maintain a consistent behavior between unix and windows.
listing running jobs:
job listThis should allow users to list what background tasks they currently have running.
killing jobs:
job kill <id>interupting nushell code in the job's background thread
interrupting the job's currently-running process, if any.
Things that should be taken into consideration for implementation:
(unix-only) Handling
TSTPsignals while executing code and turning the current program into a background job, and unfreezing them in foregroundjob unfreeze.Ensuring processes spawned by background jobs get distinct process groups from the nushell shell itself
This PR originally aimed to implement some of the following, but it is probably ideal to be left for another PR (scope creep)
job dispatch)job send/recv)Roadblocks encountered so far: