job spawn for experimental
Spawn a background job and retrieve its ID.
Command Type
built-in
Signature
> job spawn {flags} (closure)
Flags
--description, -d {string}: An optional description for this job.--auto-kill, -k: Kill this job onexitwithout warning that it is still running.
Parameters
closure: The closure to run in another thread.
Input/output types:
| input | output |
|---|---|
| nothing | int |
Examples
Spawn a background job to do some time consuming work.
> job spawn { sleep 5sec; rm evidence.pdf }Spawn a job that exit kills without warning about it.
> job spawn --auto-kill { loop { sleep 1sec } }Notes
Executes the provided closure in a background thread and registers this task in the background job table, which can be retrieved with job list.
This command returns the job id of the newly created job.
The --auto-kill flag applies to the spawned thread job. If an external process inside it is suspended and registered as a separate frozen job, it would still trigger the exit warning.