-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
40 lines (35 loc) · 809 Bytes
/
main.c
File metadata and controls
40 lines (35 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <errno.h>
#include <string.h>
#include <sys/signal.h>
#include <sys/wait.h>
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/reg.h>
#include <sys/user.h>
#include <sys/syscall.h>
#include "header.h"
int main(int argc, char* argv[])
{
if (argc > 1) {
fprintf(stderr, "usage: <program name> without params\n");
return 1;
}
pid_t TARGET_PROGRAM = fork();
switch (TARGET_PROGRAM) {
case -1:
perror("fork");
fprintf(stderr, "create fork process failed.");
exit(1);
case 0:
RUN_TARGET_PROGRAM();
break;
default:
RUN_TRACER(TARGET_PROGRAM);
break;
}
return 0;
}