Fix: Fix self-assign warning on struct ustfork_clone_info init
[lttng-ust.git] / tests / fork / fork.c
CommitLineData
e822f505
MD
1/*
2 * Copyright (C) 2009 Pierre-Marc Fournier
3 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
a09dac63
PMF
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
e822f505
MD
7 * License as published by the Free Software Foundation; version 2.1 of
8 * the License.
a09dac63
PMF
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
48c56fcf
PMF
20#include <stdio.h>
21#include <unistd.h>
cab68136 22#include <sys/types.h>
909bc43f 23#include <stdlib.h>
48c56fcf 24
deb6e540 25#define TRACEPOINT_DEFINE
e822f505
MD
26#define TRACEPOINT_CREATE_PROBES
27#include "ust_tests_fork.h"
48c56fcf 28
cab68136 29int main(int argc, char **argv, char *env[])
48c56fcf
PMF
30{
31 int result;
32
e822f505 33 if (argc < 2) {
cab68136
PMF
34 fprintf(stderr, "usage: fork PROG_TO_EXEC\n");
35 exit(1);
36 }
48c56fcf 37
cab68136 38 printf("Fork test program, parent pid is %d\n", getpid());
7083f0fe 39 tracepoint(ust_tests_fork, before_fork);
36c95a5e 40
48c56fcf 41 result = fork();
e822f505 42 if (result == -1) {
48c56fcf
PMF
43 perror("fork");
44 return 1;
45 }
e822f505
MD
46 if (result == 0) {
47 char *args[] = { "fork2", NULL };
cab68136
PMF
48
49 printf("Child pid is %d\n", getpid());
50
7083f0fe 51 tracepoint(ust_tests_fork, after_fork_child, getpid());
cab68136
PMF
52
53 result = execve(argv[1], args, env);
e822f505 54 if (result == -1) {
cab68136
PMF
55 perror("execve");
56 return 1;
57 }
e822f505 58 } else {
7083f0fe 59 tracepoint(ust_tests_fork, after_fork_parent);
48c56fcf
PMF
60 }
61
62 return 0;
63}
This page took 0.029733 seconds and 4 git commands to generate.