comparison third_party/libuv/docs/code/detach/main.c @ 160:948de3f54cea

[ThirdParty] Added libuv
author June Park <parkjune1995@gmail.com>
date Wed, 14 Jan 2026 19:39:52 -0800
parents
children
comparison
equal deleted inserted replaced
159:05cf9467a1c3 160:948de3f54cea
1 #include <stdio.h>
2
3 #include <uv.h>
4
5 uv_loop_t *loop;
6 uv_process_t child_req;
7 uv_process_options_t options;
8
9 int 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 }