Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/proc_thread_exec.c

raw
1 #include <pthread.h>
2 #include <unistd.h>
3 #include <stdio.h>
4
5 char *new_argv[] = { NULL, "3", NULL };
6
7 void *tfunc(void *arg)
8 {
9 /* Actually run the command. */
10 if (execv(new_argv[0], new_argv) < 0)
11 perror("execv");
12 return NULL;
13 }
14
15 int
16 main(int argc, char **argv)
17 {
18 pthread_t thr;
19
20 if (argc != 2) {
21 fprintf(stderr, "Usage: %s exepath\n", argv[0]);
22 return -1;
23 }
24
25 new_argv[0] = argv[1];
26
27 pthread_create(&thr, NULL, tfunc, NULL);
28 pause();
29 return 0;
30 }
31