Run as a daemon or service: Difference between revisions

Added Sidef
(PARI)
(Added Sidef)
Line 124:
(λ() (for ([i 10]) (displayln (random 1000)) (flush-output) (sleep 1))))
</lang>
 
=={{header|Sidef}}==
When the "daemon" argument is specified, a fork of the program is created with its STDOUT redirected into the file "foo.txt", and the main process is exited.
<lang ruby>var block = {
for n in (1..100) {
STDOUT.say(n)
Sys.sleep(0.5)
}
}
 
if (ARGV[0] == 'daemon') {
STDERR.say("Daemon mode")
STDOUT{:fh} = %f'foo.txt'.open_w(){:fh}
STDOUT.autoflush(true)
block.fork
STDERR.say("Exiting")
Sys.exit(0)
}
 
STDERR.say("Normal mode")
block.run</lang>
 
=={{header|Tcl}}==
2,747

edits