Lines Matching +full:- +full:- +full:pid
2 * SPDX-License-Identifier: BSD-3-Clause
58 struct pid { struct
59 SLIST_ENTRY(pid) next;
61 pid_t pid; argument
64 static SLIST_HEAD(, pid) pidlist = SLIST_HEAD_INITIALIZER(pidlist); argument
71 * Error handling is built in - if it returns, then it succeeded.
77 struct pid *cur, *p; in auto_popen()
78 pid_t pid; in auto_popen() local
90 cur = malloc(sizeof(struct pid)); in auto_popen()
110 cur->command = checked_strdup(command); in auto_popen()
112 switch (pid = fork()) { in auto_popen()
113 case -1: /* Error. */ in auto_popen()
125 close(fileno(p->outfp)); in auto_popen()
131 log_debugx("executing \"%s\" as pid %d", command, pid); in auto_popen()
134 cur->outfp = fdopen(outfds[0], "r"); in auto_popen()
139 cur->pid = pid; in auto_popen()
142 return (cur->outfp); in auto_popen()
148 struct pid *cur, *last = NULL; in auto_pclose()
150 pid_t pid; in auto_pclose() local
156 if (cur->outfp == iop) in auto_pclose()
161 return (-1); in auto_pclose()
168 fclose(cur->outfp); in auto_pclose()
171 pid = wait4(cur->pid, &status, 0, NULL); in auto_pclose()
172 } while (pid == -1 && errno == EINTR); in auto_pclose()
175 log_warnx("\"%s\", pid %d, terminated with signal %d", in auto_pclose()
176 cur->command, pid, WTERMSIG(status)); in auto_pclose()
181 log_warnx("\"%s\", pid %d, terminated with exit status %d", in auto_pclose()
182 cur->command, pid, WEXITSTATUS(status)); in auto_pclose()
186 log_debugx("\"%s\", pid %d, terminated gracefully", cur->command, pid); in auto_pclose()
188 free(cur->command); in auto_pclose()
191 return (pid == -1 ? -1 : status); in auto_pclose()