1#include <stdio.h>
2
3#include <uv.h>
4
5uv_loop_t *loop;
6uv_process_t child_req;
7uv_process_options_t options;
8
9int main() {
10    loop = uv_default_loop();
11
12    char* args[3];
13    args[0] = "sleep";
14    args[1] = "100";
15    args[2] = NULL;
16
17    options.exit_cb = NULL;
18    options.file = "sleep";
19    options.args = args;
20    options.flags = UV_PROCESS_DETACHED;
21
22    int r;
23    if ((r = uv_spawn(loop, &child_req, &options))) {
24        fprintf(stderr, "%s\n", uv_strerror(r));
25        return 1;
26    }
27    fprintf(stderr, "Launched sleep with PID %d\n", child_req.pid);
28    uv_unref((uv_handle_t*) &child_req);
29
30    return uv_run(loop, UV_RUN_DEFAULT);
31}
32