Date: Thu, 05 Feb 2026 14:10:48 +0000 From: Baptiste Daroussin <bapt@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: a3cb42ca632d - stable/15 - diff: use pdwait(2) instead of homemade one Message-ID: <6984a4e8.38f25.18aebd92@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/15 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=a3cb42ca632d674b76dc6c880d57d4980746477e commit a3cb42ca632d674b76dc6c880d57d4980746477e Author: Baptiste Daroussin <bapt@FreeBSD.org> AuthorDate: 2026-02-02 15:44:34 +0000 Commit: Baptiste Daroussin <bapt@FreeBSD.org> CommitDate: 2026-02-05 14:10:44 +0000 diff: use pdwait(2) instead of homemade one MFC After: 3 days Reviewed by: des Differential Revision: https://reviews.freebsd.org/D55053 (cherry picked from commit 0ec58e7c2e533a15eabfe8dca4a14e9ae93de4b5) --- usr.bin/diff/pr.c | 19 ++++++------------- usr.bin/diff/pr.h | 3 +-- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/usr.bin/diff/pr.c b/usr.bin/diff/pr.c index c3ea280073af..f254fbab28b7 100644 --- a/usr.bin/diff/pr.c +++ b/usr.bin/diff/pr.c @@ -28,6 +28,7 @@ #include <sys/wait.h> #include <err.h> +#include <errno.h> #include <paths.h> #include <signal.h> #include <stdio.h> @@ -72,7 +73,7 @@ start_pr(char *file1, char *file2) execl(_PATH_PR, _PATH_PR, "-h", header, (char *)0); _exit(127); default: - + pr->pidfd = pr_pd; /* parent */ if (pfd[1] != STDOUT_FILENO) { pr->ostdout = dup(STDOUT_FILENO); @@ -82,14 +83,6 @@ start_pr(char *file1, char *file2) close(pfd[0]); rewind(stdout); free(header); - pr->kq = kqueue(); - if (pr->kq == -1) - err(2, "kqueue"); - pr->e = xmalloc(sizeof(struct kevent)); - EV_SET(pr->e, pr_pd, EVFILT_PROCDESC, EV_ADD, NOTE_EXIT, 0, - NULL); - if (kevent(pr->kq, pr->e, 1, NULL, 0, NULL) == -1) - err(2, "kevent"); } return (pr); } @@ -109,10 +102,10 @@ stop_pr(struct pr *pr) dup2(pr->ostdout, STDOUT_FILENO); close(pr->ostdout); } - if (kevent(pr->kq, NULL, 0, pr->e, 1, NULL) == -1) - err(2, "kevent"); - wstatus = pr->e[0].data; - close(pr->kq); + while (pdwait(pr->pidfd, &wstatus, WEXITED, NULL, NULL) == -1) { + if (errno != EINTR) + err(2, "pdwait"); + } free(pr); if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus) != 0) errx(2, "pr exited abnormally"); diff --git a/usr.bin/diff/pr.h b/usr.bin/diff/pr.h index 2ff5949f282f..80f20ca7c329 100644 --- a/usr.bin/diff/pr.h +++ b/usr.bin/diff/pr.h @@ -28,8 +28,7 @@ struct pr { int ostdout; - int kq; - struct kevent *e; + int pidfd; }; struct pr *start_pr(char *file1, char *file2);home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6984a4e8.38f25.18aebd92>
