-
Notifications
You must be signed in to change notification settings - Fork 1
/
exe.c
46 lines (36 loc) · 821 Bytes
/
exe.c
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
39
40
41
42
43
44
45
46
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include "common.h"
#include "exe.h"
int execute_process(int pid)
{
int ret_val = 0;
#ifdef EXE
/* If a path to the gdbserver binary was specified, execute it */
char exe[FILENAME_MAX] = { 0 };
#ifdef PIDOPT
snprintf((char *) &exe, FILENAME_MAX, "%s %s %s%d", EXE, ARGS, PIDOPT, pid);
#else
snprintf((char *) &exe, FILENAME_MAX, "%s %s", EXE, ARGS);
#endif
ret_val = system((char *) &exe);
#ifdef DELAY
/* If a delay period was specified, sleep for that period */
sleep(DELAY);
#endif
#endif
return ret_val;
}
void kill_exe(void)
{
#ifdef EXE
int pid = 0;
while((pid = get_process_pid(EXE, 1)) != -1)
{
kill(pid, SIGINT);
}
usleep(KILL_EXE_SLEEP);
#endif
}