Commit | Line | Data |
---|---|---|
43c28d50 JG |
1 | /* |
2 | * Copyright (C) 2009 Pierre-Marc Fournier | |
3 | * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
4 | * | |
9d16b343 | 5 | * SPDX-License-Identifier: LGPL-2.1-only |
43c28d50 | 6 | * |
43c28d50 JG |
7 | */ |
8 | ||
9 | #include <stdio.h> | |
43c28d50 | 10 | #include <stdlib.h> |
28f23191 JG |
11 | #include <sys/types.h> |
12 | #include <unistd.h> | |
43c28d50 JG |
13 | |
14 | #define TRACEPOINT_DEFINE | |
15 | #define TRACEPOINT_CREATE_PROBES | |
16 | #include "ust_tests_daemon.h" | |
17 | ||
f46376a1 | 18 | int main(void) |
43c28d50 JG |
19 | { |
20 | int result; | |
21 | ||
43c28d50 JG |
22 | pid_t parent_pid = getpid(); |
23 | printf("parent_pid %d\n", parent_pid); | |
24 | tracepoint(ust_tests_daemon, before_daemon, parent_pid); | |
25 | ||
26 | result = daemon(0, 1); | |
27 | if (result == 0) { | |
28 | printf("child_pid %d\n", getpid()); | |
29 | ||
30 | tracepoint(ust_tests_daemon, after_daemon_child, getpid()); | |
31 | } else { | |
32 | tracepoint(ust_tests_daemon, after_daemon_parent); | |
33 | perror("daemon"); | |
34 | exit(1); | |
35 | } | |
36 | ||
37 | return 0; | |
38 | } |