# Description
This PR implements an experimental inter-job communication model,
through direct message passing, aka "mail"ing or "dm"ing:
- `job send <id>`: Sends a message the job with the given id, the root
job has id 0. Messages are stored in the recipient's "mailbox"
- `job recv`: Returns a stored message, blocks if the mailbox is empty
- `job flush`: Clear all messages from mailbox
Additionally, messages can be sent with a numeric tag, which can then be
filtered with `mail recv --tag`.
This is useful for spawning jobs and receiving messages specifically
from those jobs.
This PR is mostly a proof of concept for how inter-job communication
could look like, so people can provide feedback and suggestions
Closes #15199
May close#15220 since now jobs can access their own id.
# User-Facing Changes
Adds, `job id`, `job send`, `job recv` and `job flush` commands.
# Tests + Formatting
[X] TODO: Implement tests
[X] Consider rewriting some of the job-related tests to use this, to
make them a bit less fragile.
# After Submitting
# Description
This PR implements job tagging through the usage of a new `job tag`
command and a `--tag` for `job spawn`
Closes#15354
# User-Facing Changes
- New `job tag` command
- Job list may now have an additional `tag` column for the tag of jobs
(rows representing jobs without tags do not have this column filled)
- New `--tag` flag for `job spawn`
# Tests + Formatting
Integration tests are provided to test the newly implemented features
# After Submitting
Possibly document job tagging in the jobs documentation
# 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