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