Jump to content

Fork: Difference between revisions

136 bytes removed ,  9 years ago
m
Line 472:
 
=={{header|J}}==
This example works by calling fork in a shared object library of Ubuntu 14.04.1 LTS . OurThe Forkverb adverbgiven consumesto aadverb gerundFork consisting of tied verbs to evaluateevaluates in the appropriate parent or child process. A conjunctive form parent_verb Fork child_verb would also be reasonable.
<lang J>
load'dll'
Fork =: (('Error'"_)`('Parent'"_)`)(@.(0=[: >: [: * '/lib/x86_64-linux-gnu/libc-2.19.so __fork > x' cd [: i. 0:&[))</lang>
The child process explicitly exits, with the child remaining as a zombie process until the parent terminates.
</lang>
The child process explicitly exits, with the child remaining as a zombie process until the parent terminates.
<pre>
NB. interactive session demonstrating Fork
Line 483 ⟶ 482:
SLEEP =: 3
sleep =: SLEEP Time
([:smoutput'parent'[])`([:exit 0:[:smoutput'child'[sleep)Fork 50 NB. start the child
parent
i._2 3 4 NB. interactive computations continue in the parent process
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.