Fork: Difference between revisions
Content added Content deleted
m (Added Sidef language) |
|||
Line 143: | Line 143: | ||
((plusp pid) (write-line "This is the original process.")) |
((plusp pid) (write-line "This is the original process.")) |
||
(t (error "Something went wrong while forking."))))</lang> |
(t (error "Something went wrong while forking."))))</lang> |
||
=={{header|DCL}}== |
|||
In OpenVMS DCL, spawning a subprocess creates a partially independent process. The parent and child processes share certain pooled quotas, certain shared resources, and if the parent process is deleted then the child process is too automatically. |
|||
<lang DCL>$! looper.com procedure |
|||
$ i = 10 |
|||
$ loop: |
|||
$ show time |
|||
$ wait 'p1 |
|||
$ i = i - 1 |
|||
$ if i .gt. 0 then $ goto loop</lang> |
|||
{{out}} |
|||
<pre>$ spawn /nowait /notify @looper 0::2 ! up to 8 parameters are allowed |
|||
%DCL-S-SPAWNED, process DAVID_51258 spawned ! random number suffix assigned |
|||
$ |
|||
4-JUN-2015 13:13:50 |
|||
show default5 13:13:52 ! display anomaly due to parent and child overwriting output |
|||
4-JUN-2015 13:13:54 |
|||
USER_ROOT:[DAVID] |
|||
$ |
|||
4-JUN-2015 13:13:57 |
|||
4-JUN-2015 13:13:59 |
|||
Interrupt ! ctrl-c is the interrupt character; all child processes are deleted immediately |
|||
$ |
|||
Subprocess DAVID_51258 has completed |
|||
$</pre> |
|||
To create a more independent process requires a privilege, e.g. detach. |
|||
<lang DCL>$! fork.com procedure |
|||
$ set noverify ! detached processes have verify on by default which clutters up the output log file |
|||
$ @looper 0::2</lang> |
|||
{{out}} |
|||
<pre>$ run /detach sys$system:loginout /input = fork /output = fork |
|||
%RUN-S-PROC_ID, identification of created process is 23A4195C |
|||
$ stop/id=23A4195C ! rather than just waiting the 10 loop iterations |
|||
$ type fork.log |
|||
$! fork.com procedure |
|||
$ set noverify |
|||
4-JUN-2015 13:35:47 |
|||
4-JUN-2015 13:35:49 |
|||
4-JUN-2015 13:35:51 |
|||
4-JUN-2015 13:35:53 |
|||
4-JUN-2015 13:35:55 |
|||
4-JUN-2015 13:35:57</pre> |
|||
=={{header|Erlang}}== |
=={{header|Erlang}}== |