FreeBSD Bugzilla – Attachment 181726 Details for
Bug 218598
pwait deadlocks on its own pid
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to not wait on our own pid.
0001-Do-not-wait-for-our-own-pid.patch (text/plain), 1.22 KB, created by
Dan McGregor
on 2017-04-12 16:23:33 UTC
(
hide
)
Description:
Patch to not wait on our own pid.
Filename:
MIME Type:
Creator:
Dan McGregor
Created:
2017-04-12 16:23:33 UTC
Size:
1.22 KB
patch
obsolete
>From 8a6aae9071313f23790c0f429f8e4ece3ca130e1 Mon Sep 17 00:00:00 2001 >From: Dan McGregor <dan.mcgregor@usask.ca> >Date: Wed, 14 Sep 2016 09:16:25 -0600 >Subject: [PATCH] Do not wait for our own pid > >Fix a race condition where pwait would hang if passed its own pid. This >could happen if kern.randompid is set and a the intended waitee pid gets >recycled before pwait got called. > >Instead of deadlocking just exit immediately. >--- > bin/pwait/pwait.c | 7 +++++++ > 1 file changed, 7 insertions(+) > >diff --git a/bin/pwait/pwait.c b/bin/pwait/pwait.c >index 76989c919371..85ecc7b7b2b0 100644 >--- a/bin/pwait/pwait.c >+++ b/bin/pwait/pwait.c >@@ -71,6 +71,7 @@ main(int argc, char *argv[]) > long pid; > char *s, *end; > double timeout; >+ pid_t me; > > tflag = verbose = 0; > memset(&itv, 0, sizeof(itv)); >@@ -118,6 +119,8 @@ main(int argc, char *argv[]) > if (argc == 0) > usage(); > >+ me = getpid(); >+ > kq = kqueue(); > if (kq == -1) > err(1, "kqueue"); >@@ -136,6 +139,10 @@ main(int argc, char *argv[]) > warnx("%s: bad process id", s); > continue; > } >+ if (pid == me) { >+ warnx("%s: ignoring own process id", s); >+ continue; >+ } > duplicate = 0; > for (i = 0; i < nleft; i++) > if (e[i].ident == (uintptr_t)pid) >-- >2.12.2.89.g49800c940 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 218598
: 181726