aboutsummaryrefslogtreecommitdiff
path: root/execute_program.c
diff options
context:
space:
mode:
Diffstat (limited to 'execute_program.c')
-rw-r--r--execute_program.c58
1 files changed, 26 insertions, 32 deletions
diff --git a/execute_program.c b/execute_program.c
index 0306678..6efc03c 100644
--- a/execute_program.c
+++ b/execute_program.c
@@ -13,40 +13,9 @@
#include "ltrace.h"
#include "options.h"
-#include "output.h"
+#include "debug.h"
#include "sysdep.h"
-static void change_uid(struct process * proc);
-
-void
-execute_program(struct process * sp, char **argv) {
- pid_t pid;
-
- if (opt_d) {
- output_line(0, "Executing `%s'...", sp->filename);
- }
-
- pid = fork();
- if (pid<0) {
- perror("ltrace: fork");
- exit(1);
- } else if (!pid) { /* child */
- change_uid(sp);
- trace_me();
- execvp(sp->filename, argv);
- fprintf(stderr, "Can't execute `%s': %s\n", sp->filename, strerror(errno));
- exit(1);
- }
-
- if (opt_d) {
- output_line(0, "PID=%d", pid);
- }
-
- sp->pid = pid;
-
- return;
-}
-
static void
change_uid(struct process * proc) {
uid_t run_uid, run_euid;
@@ -97,3 +66,28 @@ change_uid(struct process * proc) {
}
}
}
+
+void
+execute_program(struct process * sp, char **argv) {
+ pid_t pid;
+
+ debug(1, "Executing `%s'...", sp->filename);
+
+ pid = fork();
+ if (pid<0) {
+ perror("ltrace: fork");
+ exit(1);
+ } else if (!pid) { /* child */
+ change_uid(sp);
+ trace_me();
+ execvp(sp->filename, argv);
+ fprintf(stderr, "Can't execute `%s': %s\n", sp->filename, strerror(errno));
+ exit(1);
+ }
+
+ debug(1, "PID=%d", pid);
+
+ sp->pid = pid;
+
+ return;
+}