X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=tests%2Fdaemon%2Fdaemon.c;fp=tests%2Fdaemon%2Fdaemon.c;h=c53074e7bd2952dd078b9b86b292eeea1d4055e4;hb=38936cf4da9aaf752fdc9c2c56e00b9ddcad8530;hp=0000000000000000000000000000000000000000;hpb=2f6150e94f4e8637b7fa30ab0c4b8930e6f026c4;p=lttng-ust.git diff --git a/tests/daemon/daemon.c b/tests/daemon/daemon.c new file mode 100644 index 00000000..c53074e7 --- /dev/null +++ b/tests/daemon/daemon.c @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2009 Pierre-Marc Fournier + * Copyright (C) 2011-2012 Mathieu Desnoyers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 of + * the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include + +#define TRACEPOINT_DEFINE +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_daemon.h" + +int main(int argc, char **argv, char *env[]) +{ + int result; + + if (argc < 1) { + fprintf(stderr, "usage: daemon\n"); + exit(1); + } + + printf("daemon test program, parent pid is %d\n", getpid()); + tracepoint(ust_tests_daemon, before_daemon); + + result = daemon(0, 1); + if (result == 0) { + printf("Child pid is %d\n", getpid()); + + tracepoint(ust_tests_daemon, after_daemon_child, getpid()); + } else { + tracepoint(ust_tests_daemon, after_daemon_parent); + perror("daemon"); + exit(1); + } + + return 0; +}