Lines Matching full:pr
37 #include "pr.h"
41 #define _PATH_PR "/usr/bin/pr"
43 struct pr *
50 struct pr *pr; in start_pr() local
52 pr = xcalloc(1, sizeof(*pr)); in start_pr()
78 pr->ostdout = dup(STDOUT_FILENO); in start_pr()
85 pr->kq = kqueue(); in start_pr()
86 if (pr->kq == -1) in start_pr()
88 pr->e = xmalloc(sizeof(struct kevent)); in start_pr()
89 EV_SET(pr->e, pr_pd, EVFILT_PROCDESC, EV_ADD, NOTE_EXIT, 0, in start_pr()
91 if (kevent(pr->kq, pr->e, 1, NULL, 0, NULL) == -1) in start_pr()
94 return (pr); in start_pr()
97 /* close the pipe to pr and restore stdout */
99 stop_pr(struct pr *pr) in stop_pr() argument
103 if (pr == NULL) in stop_pr()
107 if (pr->ostdout != STDOUT_FILENO) { in stop_pr()
109 dup2(pr->ostdout, STDOUT_FILENO); in stop_pr()
110 close(pr->ostdout); in stop_pr()
112 if (kevent(pr->kq, NULL, 0, pr->e, 1, NULL) == -1) in stop_pr()
114 wstatus = pr->e[0].data; in stop_pr()
115 close(pr->kq); in stop_pr()
116 free(pr); in stop_pr()
118 errx(2, "pr exited abnormally"); in stop_pr()
120 errx(2, "pr killed by signal %d", in stop_pr()