Commit Graph

4 Commits

Author SHA1 Message Date
cosineblast
584fb59748 Add --try flag to job recv 2025-03-29 16:03:48 -03:00
cosineblast
f8b6225f50 Improve job tests
Improves the quality of some of the job-related tests so that they
use the new communication mechanism instead of sleeping, which is more
fragile.

Unfortunately, some tests that involve child processes and PIDs
are still time-senstive, since we don't have something like named pipes
to communicate between processes.


... yet.
2025-03-26 09:02:42 -03:00
cosineblast
669f2456fe Add job messaging tests 2025-03-26 08:49:13 -03:00
Renan Ribeiro
9bb7f0c7dc
Jobs (#14883)
# Description

This is an attempt to improve the nushell situation with regard to issue
#247.

This PR implements:
- [X] 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.

- [X] listing running jobs: `job list`
This should allow users to list what background tasks they currently
have running.

- [X] killing jobs: `job kill <id>`
- [X] interupting nushell code in the job's background thread
- [X] interrupting the job's currently-running process, if any.

Things that should be taken into consideration for implementation:
- [X] (unix-only) Handling `TSTP` signals while executing code and
turning the current program into a background job, and unfreezing them
in foreground `job unfreeze`.

- [X] 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)
- Disowning external process jobs (`job dispatch`)
- Inter job communication (`job send/recv`)

Roadblocks encountered so far:
- Nushell does some weird terminal sequence magics which make so that
when a background process or thread prints something to stderr and the
prompt is idle, the stderr output ends up showing up weirdly
2025-02-25 12:09:52 -05:00