Lines Matching +full:- +full:- +full:pid

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
45 pid_t pid; member
51 pid_t pid; member
100 pid_t pid; in Popen() local
114 fd1 = -1; in Popen()
117 pid = start_command(value("SHELL"), &nset, fd0, fd1, "-c", cmd, NULL); in Popen()
118 if (pid < 0) { in Popen()
125 register_file(fp, 1, pid); in Popen()
152 if (fp_head->pipe) in close_all_files()
153 (void)Pclose(fp_head->fp); in close_all_files()
155 (void)Fclose(fp_head->fp); in close_all_files()
159 register_file(FILE *fp, int pipe, pid_t pid) in register_file() argument
165 fpp->fp = fp; in register_file()
166 fpp->pipe = pipe; in register_file()
167 fpp->pid = pid; in register_file()
168 fpp->link = fp_head; in register_file()
177 for (pp = &fp_head; (p = *pp) != NULL; pp = &p->link) in unregister_file()
178 if (p->fp == fp) { in unregister_file()
179 *pp = p->link; in unregister_file()
192 for (p = fp_head; p != NULL; p = p->link) in file_pid()
193 if (p->fp == fp) in file_pid()
194 return (p->pid); in file_pid()
201 * of stdin (-1 means none) and stdout. The command name can be a sequence
210 pid_t pid; in start_commandv() local
212 if ((pid = fork()) < 0) { in start_commandv()
214 return (-1); in start_commandv()
216 if (pid == 0) { in start_commandv()
228 return (pid); in start_commandv()
234 pid_t pid; in run_command() local
238 pid = start_commandv(cmd, nset, infd, outfd, args); in run_command()
240 if (pid < 0) in run_command()
241 return -1; in run_command()
242 return wait_command(pid); in run_command()
265 * close-on-exec. in prepare_child()
281 wait_command(pid_t pid) in wait_command() argument
284 if (wait_child(pid) < 0) { in wait_command()
286 return (-1); in wait_command()
292 findchild(pid_t pid, int dont_alloc) in findchild() argument
296 for (cpp = &child; *cpp != NULL && (*cpp)->pid != pid; in findchild()
297 cpp = &(*cpp)->link) in findchild()
304 child_freelist = (*cpp)->link; in findchild()
310 (*cpp)->pid = pid; in findchild()
311 (*cpp)->done = (*cpp)->free = 0; in findchild()
312 (*cpp)->link = NULL; in findchild()
322 for (cpp = &child; *cpp != cp; cpp = &(*cpp)->link) in delchild()
324 *cpp = cp->link; in delchild()
325 cp->link = child_freelist; in delchild()
333 pid_t pid; in sigchild() local
339 while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { in sigchild()
340 cp = findchild(pid, 1); in sigchild()
343 if (cp->free) in sigchild()
346 cp->done = 1; in sigchild()
347 cp->status = status; in sigchild()
359 wait_child(pid_t pid) in wait_child() argument
369 * If we have not already waited on the pid (via sigchild) in wait_child()
373 cp = findchild(pid, 1); in wait_child()
374 if (cp == NULL || !cp->done) in wait_child()
375 rv = waitpid(pid, &wait_status, 0); in wait_child()
377 wait_status = cp->status; in wait_child()
381 if (rv == -1 || (WIFEXITED(wait_status) && WEXITSTATUS(wait_status))) in wait_child()
382 return -1; in wait_child()
391 free_child(pid_t pid) in free_child() argument
399 if ((cp = findchild(pid, 0)) != NULL) { in free_child()
400 if (cp->done) in free_child()
403 cp->free = 1; in free_child()