Run as a daemon or service: Difference between revisions

Content added Content deleted
(PARI)
(Added Sidef)
Line 124: Line 124:
(λ() (for ([i 10]) (displayln (random 1000)) (flush-output) (sleep 1))))
(λ() (for ([i 10]) (displayln (random 1000)) (flush-output) (sleep 1))))
</lang>
</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}}==
=={{header|Tcl}}==