Lines Matching defs:pid

147 get_pathname(pid_t pid)
156 name[3] = pid;
163 pid, strerror(errno));
166 fprintf(stderr, "pid %d exited\n", pid);
170 fprintf(stderr, "No cached pathname for process %d\n", pid);
173 printf(TRACE "pid %d path %s\n", pid, pathname);
177 wait_info(int pid, int status, struct ptrace_lwpinfo *lwpinfo)
180 printf(TRACE "pid %d wait %s", pid,
190 trace_sc(int pid)
195 if (ptrace(PT_TO_SCE, pid, (caddr_t)1, 0) < 0) {
197 ptrace(PT_KILL, pid, NULL, 0);
201 if (waitpid(pid, &status, 0) == -1) {
206 wait_info(pid, status, NULL);
212 if (ptrace(PT_LWPINFO, pid, (caddr_t)&lwpinfo, sizeof(lwpinfo)) < 0) {
214 ptrace(PT_KILL, pid, NULL, 0);
217 wait_info(pid, status, &lwpinfo);
220 if (ptrace(PT_TO_SCX, pid, (caddr_t)1, 0) < 0) {
222 ptrace(PT_KILL, pid, NULL, 0);
226 if (waitpid(pid, &status, 0) == -1) {
231 wait_info(pid, status, NULL);
237 if (ptrace(PT_LWPINFO, pid, (caddr_t)&lwpinfo, sizeof(lwpinfo)) < 0) {
239 ptrace(PT_KILL, pid, NULL, 0);
242 wait_info(pid, status, &lwpinfo);
246 get_pathname(pid);
256 trace_cont(int pid)
261 if (ptrace(PT_CONTINUE, pid, (caddr_t)1, 0) < 0) {
263 ptrace(PT_KILL, pid, NULL, 0);
267 if (waitpid(pid, &status, 0) == -1) {
272 wait_info(pid, status, NULL);
278 if (ptrace(PT_LWPINFO, pid, (caddr_t)&lwpinfo, sizeof(lwpinfo)) < 0) {
280 ptrace(PT_KILL, pid, NULL, 0);
283 wait_info(pid, status, &lwpinfo);
287 get_pathname(pid);
301 trace(pid_t pid)
304 return (trace_syscalls ? trace_sc(pid) : trace_cont(pid));
313 pid_t pid, pid1;
335 if ((pid = fork()) < 0) {
339 else if (pid == 0) {
355 if (waitpid(pid, &status, 0) == -1) {
362 if (ptrace(PT_LWPINFO, pid, (caddr_t)&lwpinfo,
365 ptrace(PT_KILL, pid, NULL, 0);
368 wait_info(pid, status, &lwpinfo);
370 if (ptrace(PT_FOLLOW_FORK, pid, 0, 1) < 0) {
372 ptrace(PT_KILL, pid, NULL, 0);
376 while ((pid1 = trace(pid)) >= 0) {
378 printf(TRACE "attached to pid %d\n", pid1);
386 printf(TRACE "nested loop, pid %d status %s\n",
403 ptrace(PT_CONTINUE, pid, (caddr_t)1, 0);