Lines Matching refs:pid
346 ptrace_attach_or_seize(int pid) in ptrace_attach_or_seize() argument
351 ptrace(PTRACE_ATTACH, pid, 0L, 0L); in ptrace_attach_or_seize()
352 r = ptrace(PTRACE_SEIZE, pid, 0L, (unsigned long) ptrace_setoptions); in ptrace_attach_or_seize()
355 r = ptrace(PTRACE_INTERRUPT, pid, 0L, 0L); in ptrace_attach_or_seize()
373 ptrace(op, tcp->pid, 0L, (unsigned long) sig); in ptrace_restart()
408 perror_msg("ptrace(PTRACE_%s,pid:%d,sig:%u)", msg, tcp->pid, sig); in ptrace_restart()
436 kill_save_errno(pid_t pid, int sig) in kill_save_errno() argument
440 (void) kill(pid, sig); in kill_save_errno()
487 int pid; in strace_popen() local
496 pid = vfork(); in strace_popen()
497 if (pid < 0) in strace_popen()
500 if (pid == 0) { in strace_popen()
513 popen_pid = pid; in strace_popen()
530 perror_msg("%s.%u", outfname, tcp->pid); in outf_perror()
655 tprintf("%-5d ", tcp->pid); in printleader()
657 tprintf("[pid %5u] ", tcp->pid); in printleader()
723 xsprintf(name, "%s.%u", outfname, tcp->pid); in after_successful_attach()
756 alloctcb(int pid) in alloctcb() argument
766 if (!tcp->pid) { in alloctcb()
768 tcp->pid = pid; in alloctcb()
774 tcp->pid, nprocs); in alloctcb()
815 if (tcp->pid == 0) in droptcb()
837 debug_msg("dropped tcb for pid %d, %d remain", tcp->pid, nprocs); in droptcb()
886 error = ptrace(PTRACE_DETACH, tcp->pid, 0, 0); in detach()
893 perror_func_msg("ptrace(PTRACE_DETACH,%u)", tcp->pid); in detach()
897 if (my_tkill(tcp->pid, 0) < 0) { in detach()
900 perror_func_msg("tkill(%u,0)", tcp->pid); in detach()
912 error = ptrace(PTRACE_INTERRUPT, tcp->pid, 0, 0); in detach()
916 perror_func_msg("ptrace(PTRACE_INTERRUPT,%u)", tcp->pid); in detach()
918 error = my_tkill(tcp->pid, SIGSTOP); in detach()
922 perror_func_msg("tkill(%u,SIGSTOP)", tcp->pid); in detach()
935 if (waitpid(tcp->pid, &status, __WALL) < 0) { in detach()
943 perror_func_msg("waitpid(%u)", tcp->pid); in detach()
1014 error_msg("Process %u detached", tcp->pid); in detach()
1027 int pid; in process_opt_p_list() local
1032 pid = string_to_uint(opt); in process_opt_p_list()
1033 if (pid <= 0) { in process_opt_p_list()
1036 if (pid == strace_tracer_pid) { in process_opt_p_list()
1040 alloctcb(pid); in process_opt_p_list()
1050 if (ptrace_attach_or_seize(tcp->pid) < 0) { in attach_tcb()
1052 ptrace_attach_cmd, tcp->pid); in attach_tcb()
1058 debug_msg("attach to pid %d (main) succeeded", tcp->pid); in attach_tcb()
1065 if (followfork && tcp->pid != strace_child && in attach_tcb()
1066 xsprintf(procdir, task_path, tcp->pid) > 0 && in attach_tcb()
1075 if (tid <= 0 || tid == tcp->pid) in attach_tcb()
1098 tcp->pid, ntid - nerr + 1); in attach_tcb()
1101 tcp->pid); in attach_tcb()
1113 pid_t pid = fork(); in startup_attach() local
1114 if (pid < 0) in startup_attach()
1117 if (pid) { /* parent */ in startup_attach()
1135 if (!tcp->pid) in startup_attach()
1142 if (tcp->pid == parent_pid || tcp->pid == strace_tracer_pid) { in startup_attach()
1144 perror_msg("attach: pid %d", tcp->pid); in startup_attach()
1306 int pid; in startup_child() local
1384 pid = fork(); in startup_child()
1385 if (pid < 0) in startup_child()
1388 if ((pid != 0 && daemonized_tracer) in startup_child()
1389 || (pid == 0 && !daemonized_tracer) in startup_child()
1401 strace_child = pid; in startup_child()
1408 while (waitpid(pid, &status, WSTOPPED) < 0) { in startup_child()
1414 kill_save_errno(pid, SIGKILL); in startup_child()
1424 if (ptrace_attach_or_seize(pid)) { in startup_child()
1425 kill_save_errno(pid, SIGKILL); in startup_child()
1427 ptrace_attach_cmd, pid); in startup_child()
1430 kill(pid, SIGCONT); in startup_child()
1432 tcp = alloctcb(pid); in startup_child()
1486 int pid; in test_ptrace_seize() local
1494 pid = fork(); in test_ptrace_seize()
1495 if (pid < 0) in test_ptrace_seize()
1498 if (pid == 0) { in test_ptrace_seize()
1507 if (ptrace(PTRACE_SEIZE, pid, 0, 0) == 0) { in test_ptrace_seize()
1513 kill(pid, SIGKILL); in test_ptrace_seize()
1519 tracee_pid = waitpid(pid, &status, 0); in test_ptrace_seize()
1933 pid2tcb(const int pid) in pid2tcb() argument
1935 if (pid <= 0) in pid2tcb()
1942 struct tcb **const ptcp = &pid2tcb_cache[pid & PID2TCB_CACHE_MASK]; in pid2tcb()
1945 if (tcp && tcp->pid == pid) in pid2tcb()
1950 if (tcp->pid == pid) in pid2tcb()
1971 if (!tcp->pid) in cleanup()
1973 debug_func_msg("looking at pid %u", tcp->pid); in cleanup()
1974 if (tcp->pid == strace_child) { in cleanup()
1975 kill(tcp->pid, SIGCONT); in cleanup()
1976 kill(tcp->pid, fatal_sig); in cleanup()
1991 print_debug_info(const int pid, int status) in print_debug_info() argument
2029 error_msg("[wait(0x%06x) = %u] %s%s", status, pid, buf, evbuf); in print_debug_info()
2033 maybe_allocate_tcb(const int pid, int status) in maybe_allocate_tcb() argument
2036 if (detach_on_execve && pid == strace_child) { in maybe_allocate_tcb()
2045 error_msg("Exit of unknown pid %u ignored", pid); in maybe_allocate_tcb()
2050 struct tcb *tcp = alloctcb(pid); in maybe_allocate_tcb()
2053 error_msg("Process %d attached", pid); in maybe_allocate_tcb()
2063 ptrace(PTRACE_DETACH, pid, NULL, 0L); in maybe_allocate_tcb()
2064 error_msg("Detached unknown pid %d", pid); in maybe_allocate_tcb()
2070 maybe_switch_tcbs(struct tcb *tcp, const int pid) in maybe_switch_tcbs() argument
2076 if (ptrace(PTRACE_GETEVENTMSG, pid, NULL, &old_pid) < 0) in maybe_switch_tcbs()
2079 if (old_pid <= 0 || old_pid == pid) in maybe_switch_tcbs()
2093 fprintf(execve_thread->outf, " <pid changed to %d ...>\n", pid); in maybe_switch_tcbs()
2107 tcp->pid = pid; in maybe_switch_tcbs()
2119 print_signalled(struct tcb *tcp, const int pid, int status) in print_signalled() argument
2121 if (pid == strace_child) { in print_signalled()
2142 print_exited(struct tcb *tcp, const int pid, int status) in print_exited() argument
2144 if (pid == strace_child) { in print_exited()
2182 debug_msg("pid %d has TCB_STARTUP, initializing it", tcp->pid); in startup_tcb()
2188 ptrace_setoptions, tcp->pid); in startup_tcb()
2189 if (ptrace(PTRACE_SETOPTIONS, tcp->pid, NULL, ptrace_setoptions) < 0) { in startup_tcb()
2245 int pid; in next_event() local
2295 pid = wait4(-1, &status, __WALL, (cflag ? &ru : NULL)); in next_event()
2312 if (pid < 0) { in next_event()
2329 if (pid == popen_pid) { in next_event()
2337 print_debug_info(pid, status); in next_event()
2340 tcp = pid2tcb(pid); in next_event()
2343 tcp = maybe_allocate_tcb(pid, status); in next_event()
2397 debug_func_msg("ignored SIGSTOP on pid %d", tcp->pid); in next_event()
2410 bool stopped = ptrace(PTRACE_GETSIGINFO, pid, 0, &wd->si) < 0; in next_event()
2513 print_signalled(current_tcp, current_tcp->pid, status); in dispatch_event()
2533 print_exited(current_tcp, current_tcp->pid, status); in dispatch_event()
2551 current_tcp->pid); in dispatch_event()
2580 current_tcp->pid)); in dispatch_event()
2618 debug_func_msg("pid %d", tcp->pid); in restart_delayed_tcb()
2641 if (tcp->pid && syscall_delayed(tcp)) { in restart_delayed_tcbs()