Markers: remove channel name from trace_mark()
[ust.git] / tests / fork / fork.c
CommitLineData
a09dac63
PMF
1/* Copyright (C) 2009 Pierre-Marc Fournier
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
48c56fcf
PMF
18#include <stdio.h>
19#include <unistd.h>
cab68136 20#include <sys/types.h>
909bc43f 21#include <stdlib.h>
48c56fcf 22
93d0f2ea 23#include <ust/marker.h>
48c56fcf 24
cab68136 25int main(int argc, char **argv, char *env[])
48c56fcf
PMF
26{
27 int result;
28
cab68136
PMF
29 if(argc < 2 ) {
30 fprintf(stderr, "usage: fork PROG_TO_EXEC\n");
31 exit(1);
32 }
48c56fcf 33
cab68136 34 printf("Fork test program, parent pid is %d\n", getpid());
37ee34e4 35 trace_mark(before_fork, MARK_NOARGS);
48c56fcf 36
36c95a5e
YB
37 /* Sleep here to make sure the consumer is initialized before we fork */
38 sleep(1);
39
48c56fcf
PMF
40 result = fork();
41 if(result == -1) {
42 perror("fork");
43 return 1;
44 }
45 if(result == 0) {
cab68136
PMF
46 char *args[] = {"fork2", NULL};
47
48 printf("Child pid is %d\n", getpid());
49
37ee34e4 50 trace_mark(after_fork_child, MARK_NOARGS);
cab68136 51
37ee34e4 52 trace_mark(before_exec, "pid %d", getpid());
cab68136
PMF
53
54 result = execve(argv[1], args, env);
55 if(result == -1) {
56 perror("execve");
57 return 1;
58 }
59
37ee34e4 60 trace_mark(after_exec, "pid %d", getpid());
48c56fcf
PMF
61 }
62 else {
37ee34e4 63 trace_mark(after_fork_parent, MARK_NOARGS);
48c56fcf
PMF
64 }
65
66 return 0;
67}
This page took 0.035917 seconds and 4 git commands to generate.