tests/fork: updates
[ust.git] / tests / fork / fork.c
1 #include <stdio.h>
2 #include <unistd.h>
3 #include <sys/types.h>
4
5 #include "marker.h"
6
7
8 int main(int argc, char **argv, char *env[])
9 {
10 int result;
11
12 if(argc < 2 ) {
13 fprintf(stderr, "usage: fork PROG_TO_EXEC\n");
14 exit(1);
15 }
16
17 printf("Fork test program, parent pid is %d\n", getpid());
18 trace_mark(ust, before_fork, MARK_NOARGS);
19
20 result = fork();
21 if(result == -1) {
22 perror("fork");
23 return 1;
24 }
25 if(result == 0) {
26 char *args[] = {"fork2", NULL};
27
28 printf("Child pid is %d\n", getpid());
29
30 trace_mark(ust, after_fork_child, MARK_NOARGS);
31
32 trace_mark(ust, before_exec, "pid %d", getpid());
33
34 result = execve(argv[1], args, env);
35 if(result == -1) {
36 perror("execve");
37 return 1;
38 }
39
40 trace_mark(ust, after_exec, "pid %d", getpid());
41 }
42 else {
43 trace_mark(ust, after_fork_parent, MARK_NOARGS);
44 }
45
46 return 0;
47 }
48
49 MARKER_LIB;
This page took 0.029324 seconds and 4 git commands to generate.