This source file includes following definitions.
- print_usage
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <config.h>
21
22 #include <signal.h>
23 #include <stdio.h>
24 #include <unistd.h>
25 #include <stdlib.h>
26 #include <errno.h>
27 #include <string.h>
28
29 #include <sys/wait.h>
30
31 #include "exec.h"
32
33
34
35 static void
36 print_usage (void)
37 {
38 fprintf (stderr, "test loader-name program [args...]\n"
39 "Run the given program using the specified loader.\n");
40 }
41
42
43
44 extern char **environ;
45
46
47
48
49 int
50 main (int argc, char **argv)
51 {
52 pid_t pid, child;
53 int sig;
54 sigset_t sigset;
55
56
57
58 if (argc < 3)
59 {
60 print_usage ();
61 return 1;
62 }
63
64 exec_init (argv[1]);
65
66
67
68
69 sigemptyset (&sigset);
70 sigaddset (&sigset, SIGCHLD);
71 sigprocmask (SIG_BLOCK, &sigset, NULL);
72
73 if (!(pid = fork ()))
74 {
75 tracing_execve (argv[2], argv + 2, environ);
76 fprintf (stderr, "tracing_execve: %s\n",
77 strerror (errno));
78 exit (1);
79 }
80 else if (after_fork (pid))
81 {
82 fprintf (stderr, "after_fork: %s\n",
83 strerror (errno));
84 exit (1);
85 }
86
87
88
89 while (true)
90 {
91 child = exec_waitpid (-1, &sig, 0);
92
93
94
95 if (child == -1)
96 continue;
97
98
99
100 if (child == pid && !WIFSTOPPED (sig))
101 return (WIFEXITED (sig)
102 ? WEXITSTATUS (sig)
103 : WTERMSIG (sig));
104 }
105 }