Run as a daemon or service: Difference between revisions

Line 320:
STDERR.say("Normal mode")
block.run</lang>
 
=={{header|Smalltalk}}==
{{works with |Smalltalk/X}}
<lang smalltalk>(pid := OperatingSystem fork) == 0 ifTrue:[
Stdin close.
Stdout := '/tmp/daemon.log' asFilename writeStream.
Stdout buffered:false. "so we can watch it growing"
Transcript := Stderr := Stdout.
 
Stdout showCR: e'here is the child'.
1 to:5 do:[:n |
Delay waitForSeconds:5.
Transcript showCR: e'another hello on Transcript {n}'.
].
] ifFalse:[
Stdout showCR: e'forked new process pid={pid}; now exiting'.
OperatingSystem exit:0
]</lang>
{{out}}
<pre>forked new process pid=77897; now exiting
... after a few seconds:
cat /tmp/daemon.log
here is the child
another hello on Transcript 1
another hello on Transcript 2
another hello on Transcript 3
another hello on Transcript 4
another hello on Transcript 5</pre>
 
=={{header|Tcl}}==
Anonymous user