projects
/
ust.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tests/fork: updates
[ust.git]
/
tests
/
fork
/
fork.c
diff --git
a/tests/fork/fork.c
b/tests/fork/fork.c
index 20a08779f367cc413d2da769c0b25853797f90ec..677261b17d7c7d03eb91d655f9052450307a42f7 100644
(file)
--- a/
tests/fork/fork.c
+++ b/
tests/fork/fork.c
@@
-1,17
+1,21
@@
#include <stdio.h>
#include <unistd.h>
#include <stdio.h>
#include <unistd.h>
+#include <sys/types.h>
#include "marker.h"
#include "marker.h"
-int main()
+int main(
int argc, char **argv, char *env[]
)
{
int result;
{
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) {
result = fork();
if(result == -1) {
@@
-19,7
+23,21
@@
int main()
return 1;
}
if(result == 0) {
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, 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);
}
else {
trace_mark(ust, after_fork_parent, MARK_NOARGS);
This page took
0.024007 seconds
and
4
git commands to generate.