Date: Thu, 30 Oct 2025 23:52:27 GMT From: Colin Percival <cperciva@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 936ef70cea27 - releng/15.0 - pwait: Avoid calling getpid(2) for each proc. Message-ID: <202510302352.59UNqRAl087167@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch releng/15.0 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=936ef70cea271411314abce6542586208d4908eb commit 936ef70cea271411314abce6542586208d4908eb Author: Bryan Drewery <bdrewery@FreeBSD.org> AuthorDate: 2025-10-10 18:00:35 +0000 Commit: Colin Percival <cperciva@FreeBSD.org> CommitDate: 2025-10-30 23:48:22 +0000 pwait: Avoid calling getpid(2) for each proc. Approved by: re (cperciva) (cherry picked from commit ab4abce6c2c2091a3b9ea1f38cbef94ee7a68090) (cherry picked from commit 54d1d527c8edf1e6819af7aadae744095116a27d) --- bin/pwait/pwait.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/pwait/pwait.c b/bin/pwait/pwait.c index a78c0bb84ca8..27f4c8e9858d 100644 --- a/bin/pwait/pwait.c +++ b/bin/pwait/pwait.c @@ -64,6 +64,7 @@ main(int argc, char *argv[]) char *end, *s; double timeout; long pid; + pid_t mypid; int i, kq, n, nleft, opt, status; bool oflag, tflag, verbose; @@ -137,6 +138,7 @@ main(int argc, char *argv[]) err(EX_OSERR, "malloc"); } nleft = 0; + mypid = getpid(); for (n = 0; n < argc; n++) { s = argv[n]; /* Undocumented Solaris compat */ @@ -149,7 +151,7 @@ main(int argc, char *argv[]) warnx("%s: bad process id", s); continue; } - if (pid == getpid()) { + if (pid == mypid) { warnx("%s: skipping my own pid", s); continue; }home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202510302352.59UNqRAl087167>
