From: Pierre-Marc Fournier Date: Tue, 13 Oct 2009 23:12:45 +0000 (-0400) Subject: tests/fork: updates X-Git-Tag: v0.1~86 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=cab681366d2cf9039b3cfb8b8ce97ddaf6b5ba53;p=ust.git tests/fork: updates --- diff --git a/tests/fork/fork.c b/tests/fork/fork.c index 20a0877..677261b 100644 --- a/tests/fork/fork.c +++ b/tests/fork/fork.c @@ -1,17 +1,21 @@ #include #include +#include #include "marker.h" -int main() +int main(int argc, char **argv, char *env[]) { int result; - printf("Fork test program\n"); - trace_mark(ust, before_fork, MARK_NOARGS); + if(argc < 2 ) { + fprintf(stderr, "usage: fork PROG_TO_EXEC\n"); + exit(1); + } - sleep(5); + printf("Fork test program, parent pid is %d\n", getpid()); + trace_mark(ust, before_fork, MARK_NOARGS); result = fork(); if(result == -1) { @@ -19,7 +23,21 @@ int main() return 1; } if(result == 0) { + char *args[] = {"fork2", NULL}; + + printf("Child pid is %d\n", getpid()); + trace_mark(ust, after_fork_child, MARK_NOARGS); + + trace_mark(ust, before_exec, "pid %d", getpid()); + + result = execve(argv[1], args, env); + if(result == -1) { + perror("execve"); + return 1; + } + + trace_mark(ust, after_exec, "pid %d", getpid()); } else { trace_mark(ust, after_fork_parent, MARK_NOARGS);