X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fdaemonize.hpp;fp=src%2Fcommon%2Fdaemonize.hpp;h=d1ec1cb424400382fde60e02928f5c40ee91b460;hb=c9e313bc594f40a86eed237dce222c0fc99c957f;hp=0000000000000000000000000000000000000000;hpb=4878de5c7deb512bbdac4fdfc498907efa06fb7c;p=lttng-tools.git diff --git a/src/common/daemonize.hpp b/src/common/daemonize.hpp new file mode 100644 index 000000000..d1ec1cb42 --- /dev/null +++ b/src/common/daemonize.hpp @@ -0,0 +1,28 @@ +#ifndef LTTNG_DAEMONIZE_H +#define LTTNG_DAEMONIZE_H + +/* + * Copyright (C) 2013 David Goulet + * Copyright (C) 2014 Mathieu Desnoyers + * + * SPDX-License-Identifier: GPL-2.0-only + * + */ + +#include +#include + +/* + * Daemonize this process by forking and making the parent wait for the child + * to signal it indicating readiness. Once received, the parent successfully + * quits. + * + * The child process undergoes the same action that daemon(3) does meaning + * setsid, chdir, and dup /dev/null into 0, 1 and 2. + * + * Return 0 on success else -1 on error. + */ +int lttng_daemonize(pid_t *child_ppid, int *completion_flag, + int close_fds); + +#endif /* LTTNG_DAEMONIZE_H */