nushell/crates/nu-system
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
..
examples Reduce again the number of match calls (#7815) 2023-01-24 12:23:42 +01:00
src Jobs (#14883) 2025-02-25 12:09:52 -05:00
.gitignore Add nu-system and rewrite ps command (#734) 2022-01-14 17:20:53 +11:00
Cargo.toml Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
LICENSE Nu glob (#4818) 2022-03-13 11:30:27 -07:00
README.md Add top-level crate documentation/READMEs (#12907) 2024-07-14 10:10:41 +02:00

Operating system specific bindings used by Nushell.

Currently primarily wrappers around processes and ways to gather process info from the system

Internal Nushell crate

This crate implements components of Nushell and is not designed to support plugin authors or other users directly.