Lines Matching refs:pid
40 static void test_get_process_comm_one(pid_t pid) { in test_get_process_comm_one() argument
53 xsprintf(path, "/proc/"PID_FMT"/comm", pid); in test_get_process_comm_one()
56 assert_se(get_process_comm(pid, &a) >= 0); in test_get_process_comm_one()
57 log_info("PID"PID_FMT" comm: '%s'", pid, a); in test_get_process_comm_one()
61 assert_se(get_process_cmdline(pid, 0, PROCESS_CMDLINE_COMM_FALLBACK, &c) >= 0); in test_get_process_comm_one()
62 log_info("PID"PID_FMT" cmdline: '%s'", pid, c); in test_get_process_comm_one()
64 assert_se(get_process_cmdline(pid, 8, 0, &d) >= 0); in test_get_process_comm_one()
65 log_info("PID"PID_FMT" cmdline truncated to 8: '%s'", pid, d); in test_get_process_comm_one()
68 assert_se(get_process_cmdline(pid, 1, 0, &d) >= 0); in test_get_process_comm_one()
69 log_info("PID"PID_FMT" cmdline truncated to 1: '%s'", pid, d); in test_get_process_comm_one()
71 r = get_process_ppid(pid, &e); in test_get_process_comm_one()
72 assert_se(pid == 1 ? r == -EADDRNOTAVAIL : r >= 0); in test_get_process_comm_one()
74 log_info("PID"PID_FMT" PPID: "PID_FMT, pid, e); in test_get_process_comm_one()
78 assert_se(is_kernel_thread(pid) == 0 || pid != 1); in test_get_process_comm_one()
80 r = get_process_exe(pid, &f); in test_get_process_comm_one()
82 log_info("PID"PID_FMT" exe: '%s'", pid, strna(f)); in test_get_process_comm_one()
84 assert_se(get_process_uid(pid, &u) == 0); in test_get_process_comm_one()
85 log_info("PID"PID_FMT" UID: "UID_FMT, pid, u); in test_get_process_comm_one()
87 assert_se(get_process_gid(pid, &g) == 0); in test_get_process_comm_one()
88 log_info("PID"PID_FMT" GID: "GID_FMT, pid, g); in test_get_process_comm_one()
90 r = get_process_environ(pid, &env); in test_get_process_comm_one()
92 … log_info("PID"PID_FMT" strlen(environ): %zi", pid, env ? (ssize_t)strlen(env) : (ssize_t)-errno); in test_get_process_comm_one()
95 assert_se(get_ctty_devnr(pid, &h) == -ENXIO || pid != 1); in test_get_process_comm_one()
97 (void) getenv_for_pid(pid, "PATH", &i); in test_get_process_comm_one()
98 log_info("PID"PID_FMT" $PATH: '%s'", pid, strna(i)); in test_get_process_comm_one()
103 pid_t pid = 0; in TEST() local
105 (void) parse_pid(saved_argv[1], &pid); in TEST()
106 test_get_process_comm_one(pid); in TEST()
113 static void test_get_process_cmdline_one(pid_t pid) { in test_get_process_cmdline_one() argument
117 r = get_process_cmdline(pid, SIZE_MAX, 0, &c); in test_get_process_cmdline_one()
118 log_info("PID "PID_FMT": %s", pid, r >= 0 ? c : errno_to_name(r)); in test_get_process_cmdline_one()
120 r = get_process_cmdline(pid, SIZE_MAX, PROCESS_CMDLINE_COMM_FALLBACK, &d); in test_get_process_cmdline_one()
123 r = get_process_cmdline(pid, SIZE_MAX, PROCESS_CMDLINE_QUOTE, &e); in test_get_process_cmdline_one()
126 … r = get_process_cmdline(pid, SIZE_MAX, PROCESS_CMDLINE_QUOTE | PROCESS_CMDLINE_COMM_FALLBACK, &f); in test_get_process_cmdline_one()
129 r = get_process_cmdline(pid, SIZE_MAX, PROCESS_CMDLINE_QUOTE_POSIX, &g); in test_get_process_cmdline_one()
132 …r = get_process_cmdline(pid, SIZE_MAX, PROCESS_CMDLINE_QUOTE_POSIX | PROCESS_CMDLINE_COMM_FALLBACK… in test_get_process_cmdline_one()
142 pid_t pid; in TEST() local
147 if (parse_pid(de->d_name, &pid) < 0) in TEST()
150 test_get_process_cmdline_one(pid); in TEST()
187 pid_t pid; in TEST() local
189 pid = fork(); in TEST()
190 assert_se(pid >= 0); in TEST()
191 if (pid == 0) { in TEST()
196 waitpid(pid, &status, 0); in TEST()
197 assert_se(!pid_is_unwaited(pid)); in TEST()
204 pid_t pid; in TEST() local
206 pid = fork(); in TEST()
207 assert_se(pid >= 0); in TEST()
208 if (pid == 0) { in TEST()
213 waitpid(pid, &status, 0); in TEST()
214 assert_se(!pid_is_alive(pid)); in TEST()
246 pid_t pid; in TEST() local
268 pid = fork(); in TEST()
269 if (pid > 0) { in TEST()
272 (void) wait_for_terminate(pid, &si); in TEST()
280 assert_se(pid == 0); in TEST()
575 pid_t pid; in test_rename_process_one() local
579 pid = fork(); in test_rename_process_one()
580 assert_se(pid >= 0); in test_rename_process_one()
582 if (pid == 0) { in test_rename_process_one()
588 assert_se(wait_for_terminate(pid, &si) >= 0); in test_rename_process_one()
594 pid_t pid; in TEST() local
596 pid = fork(); in TEST()
597 assert_se(pid >= 0); in TEST()
599 if (pid > 0) { in TEST()
602 assert_se(wait_for_terminate(pid, &si) >= 0); in TEST()
688 pid_t pid; in TEST() local
693 …hild)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DEATHSIG|FORK_NULL_STDIO|FORK_REOPEN_LOG, &pid); in TEST()
703 assert_se(wait_for_terminate(pid, &status) >= 0); in TEST()
859 for (pid_t pid = 0;;) { in TEST() local
863 r = get_process_ppid(pid, &ppid); in TEST()
871 … assert_se(get_process_cmdline(pid, SIZE_MAX, PROCESS_CMDLINE_COMM_FALLBACK, &c1) >= 0); in TEST()
874 log_info("Parent of " PID_FMT " (%s) is " PID_FMT " (%s).", pid, c1, ppid, c2); in TEST()
876 pid = ppid; in TEST()