/
niceSOFT
/
libuv
Обзор
Документация
Войти
/
niceSOFT
/
libuv
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
v1.x
docs/code/detach/main.c
31 строка
651 B
Saúl Ibarra Corretgé
doc: add code samples from uvbook (unadapted)
28 апр 2017, 12:16
28 апр 2017, 12:16
d59d6e6
Код
Авторство
О чём код?
#include <stdio.h> #include <uv.h> uv_loop_t *loop; uv_process_t child_req; uv_process_options_t options; int main() { loop = uv_default_loop(); char* args[3]; args[0] = "sleep"; args[1] = "100"; args[2] = NULL; options.exit_cb = NULL; options.file = "sleep"; options.args = args; options.flags = UV_PROCESS_DETACHED; int r; if ((r = uv_spawn(loop, &child_req, &options))) { fprintf(stderr, "%s\n", uv_strerror(r)); return 1; } fprintf(stderr, "Launched sleep with PID %d\n", child_req.pid); uv_unref((uv_handle_t*) &child_req); return uv_run(loop, UV_RUN_DEFAULT); }