diff options
| author | Bryan Drewery <bdrewery@FreeBSD.org> | 2025-10-10 11:00:35 -0700 |
|---|---|---|
| committer | Bryan Drewery <bdrewery@FreeBSD.org> | 2025-10-23 17:01:58 -0700 |
| commit | ab4abce6c2c2091a3b9ea1f38cbef94ee7a68090 (patch) | |
| tree | 031e069ae526b7547cbbcd07e979c20ae5fbb8d0 /bin | |
| parent | d1ca01059d5d756a4aef09d955e98aa59a284344 (diff) | |
pwait: Avoid calling getpid(2) for each proc.
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/pwait/pwait.c | 4 |
1 files changed, 3 insertions, 1 deletions
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; } |
