File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,35 @@ job unfreeze 1
9191# we're back in vim
9292```
9393
94+ ## Communicating between jobs
95+
96+ Data can be sent to a job using ` job send <id> ` , and the job can receive it using ` job recv ` :
97+
98+ ``` nu
99+ let jobId = job spawn {
100+ job recv | save sent.txt
101+ }
102+
103+ 'hello from the main thread' | job send $jobId
104+
105+ sleep 1sec
106+
107+ open sent.txt
108+ # => hello from the main thread
109+ ```
110+
111+ The main thread has a job ID of 0, so you can also send data in the other direction:
112+
113+ ``` nu
114+ job spawn {
115+ sleep 1sec
116+ 'Hello from a background job' | job send 0
117+ }
118+
119+ job recv
120+ # => Hello from a background job
121+ ```
122+
94123## Exit Behavior
95124
96125Unlike many other shells, Nushell jobs are ** not** separate processes,
You can’t perform that action at this time.
0 commit comments