|
Lines 55-60
Link Here
|
| 55 |
|
55 |
|
| 56 |
#include "extern.h" |
56 |
#include "extern.h" |
| 57 |
|
57 |
|
|
|
58 |
extern char *procpath; |
| 59 |
|
| 58 |
static int evflags = 0; |
60 |
static int evflags = 0; |
| 59 |
|
61 |
|
| 60 |
/* |
62 |
/* |
|
Lines 67-73
Link Here
|
| 67 |
int |
69 |
int |
| 68 |
setup_and_wait(char *command[]) { |
70 |
setup_and_wait(char *command[]) { |
| 69 |
struct procfs_status pfs; |
71 |
struct procfs_status pfs; |
| 70 |
char buf[32]; |
72 |
char buf[MAXPATHLEN]; |
| 71 |
int fd; |
73 |
int fd; |
| 72 |
int pid; |
74 |
int pid; |
| 73 |
int flags; |
75 |
int flags; |
|
Lines 78-86
Link Here
|
| 78 |
} |
80 |
} |
| 79 |
if (pid == 0) { /* Child */ |
81 |
if (pid == 0) { /* Child */ |
| 80 |
int mask = S_EXEC | S_EXIT; |
82 |
int mask = S_EXEC | S_EXIT; |
| 81 |
fd = open("/proc/curproc/mem", O_WRONLY); |
83 |
snprintf(buf, sizeof buf, "%s/curproc/mem", procpath); |
|
|
84 |
fd = open(buf, O_WRONLY); |
| 82 |
if (fd == -1) |
85 |
if (fd == -1) |
| 83 |
err(2, "cannot open /proc/curproc/mem"); |
86 |
err(2, "cannot open %s", buf); |
| 84 |
fcntl(fd, F_SETFD, 1); |
87 |
fcntl(fd, F_SETFD, 1); |
| 85 |
if (ioctl(fd, PIOCBIS, mask) == -1) |
88 |
if (ioctl(fd, PIOCBIS, mask) == -1) |
| 86 |
err(3, "PIOCBIS"); |
89 |
err(3, "PIOCBIS"); |
|
Lines 107-113
Link Here
|
| 107 |
exit(1); |
110 |
exit(1); |
| 108 |
} |
111 |
} |
| 109 |
|
112 |
|
| 110 |
sprintf(buf, "/proc/%d/mem", pid); |
113 |
snprintf(buf, MAXPATHLEN, "%s/%d/mem", procpath, pid); |
| 111 |
if ((fd = open(buf, O_RDWR)) == -1) |
114 |
if ((fd = open(buf, O_RDWR)) == -1) |
| 112 |
err(5, "cannot open %s", buf); |
115 |
err(5, "cannot open %s", buf); |
| 113 |
if (ioctl(fd, PIOCWAIT, &pfs) == -1) |
116 |
if (ioctl(fd, PIOCWAIT, &pfs) == -1) |
|
Lines 131-139
Link Here
|
| 131 |
int |
134 |
int |
| 132 |
start_tracing(int pid, int flags) { |
135 |
start_tracing(int pid, int flags) { |
| 133 |
int fd; |
136 |
int fd; |
| 134 |
char buf[32]; |
137 |
char buf[MAXPATHLEN]; |
| 135 |
struct procfs_status tmp; |
138 |
struct procfs_status tmp; |
| 136 |
sprintf(buf, "/proc/%d/mem", pid); |
139 |
snprintf(buf, sizeof buf, "%s/%d/mem", procpath, pid); |
| 137 |
|
140 |
|
| 138 |
fd = open(buf, O_RDWR); |
141 |
fd = open(buf, O_RDWR); |
| 139 |
if (fd == -1) { |
142 |
if (fd == -1) { |