2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1 +1,4 @@
|
|||
In this task, the goal is to spawn a new [[process]] which can run simultaneously with, and independently of, the original parent process.
|
||||
;Task:
|
||||
|
||||
Spawn a new [[process]] which can run simultaneously with, and independently of, the original parent process.
|
||||
<br><br>
|
||||
|
|
|
|||
30
Task/Fork/COBOL/fork.cobol
Normal file
30
Task/Fork/COBOL/fork.cobol
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
identification division.
|
||||
program-id. forking.
|
||||
|
||||
data division.
|
||||
working-storage section.
|
||||
01 pid usage binary-long.
|
||||
|
||||
procedure division.
|
||||
display "attempting fork"
|
||||
|
||||
call "fork" returning pid
|
||||
on exception
|
||||
display "error: no fork linkage" upon syserr
|
||||
end-call
|
||||
|
||||
evaluate pid
|
||||
when = 0
|
||||
display " child sleeps"
|
||||
call "C$SLEEP" using 3
|
||||
display " child task complete"
|
||||
when < 0
|
||||
display "error: fork result not ok" upon syserr
|
||||
when > 0
|
||||
display "parent waits for child..."
|
||||
call "wait" using by value 0
|
||||
display "parental responsibilities fulfilled"
|
||||
end-evaluate
|
||||
|
||||
goback.
|
||||
end program forking.
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use NativeCall;
|
||||
sub fork() returns Int is native { ... }
|
||||
sub fork() returns int32 is native { ... }
|
||||
|
||||
if fork() -> $pid {
|
||||
print "I am the proud parent of $pid.\n";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue