Run as a daemon or service: Difference between revisions

m
→‎{{header|Wren}}: Minor tidy and rerun
m (syntax highlighting fixup automation)
m (→‎{{header|Wren}}: Minor tidy and rerun)
 
Line 578:
An embedded program but the actual daemon is of course the C host even though the process is orchestrated by the Wren code which handles any errors and prints the time every second to the file.
 
The following script is based on the C example though modified a little to run on Ubuntu 2022.04.
<syntaxhighlight lang="ecmascriptwren">/* dumperRun_as_a_daemon_or_service.wren */
 
import "./date" for Date
Line 642:
<br>
We now embed this in the following C program, compile and run it.
<syntaxhighlight lang="c">/* gcc dumperRun_as_a_daemon_or_service.c -o dumper -lwren -lm */
 
#include <fcntl.h>
Line 775:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "dumperRun_as_a_daemon_or_service.wren";
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
Line 798:
$ ./dumper dump
$ tail -f dump
Sat DecFeb 1803 1620:5802:2620 20212024
Sat DecFeb 1803 1620:5802:2721 20212024
Sat DecFeb 1803 1620:5802:2822 20212024
Sat DecFeb 1803 1620:5802:2923 20212024
Sat DecFeb 1803 1620:5802:3024 20212024
Sat DecFeb 1803 1620:5802:3125 20212024
Sat DecFeb 1803 1620:5802:3226 20212024
Sat DecFeb 1803 1620:5802:3327 20212024
Sat DecFeb 1803 1620:5802:3428 20212024
Sat DecFeb 1803 1620:5802:3529 20212024
^C
$ pkill -x dumper
9,476

edits