Anonymous user
Fork: Difference between revisions
Added COBOL
m (→{{header|LFE}}: Tweaked for LFE) |
(Added COBOL) |
||
Line 129:
(do-something-with out)
(report-errors-in err))))</lang>
=={{header|COBOL}}==
Using libc fork
{{works with|GnuCOBOL}}
<lang cobol> 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.</lang>
{{out}}
<pre>prompt$ cobc -xj forking.cob
attempting fork
parent waits for child...
child sleeps
child task complete
parental responsibilities fulfilled</pre>
=={{header|Common Lisp}}==
|