Date: Sun, 23 Jun 2002 09:07:15 -0400 (EDT) From: "Geoffrey C. Speicher" <geoff@sea-incorporated.com> To: "Matthew D. Fuller" <fullermd@over-yonder.net> Cc: freebsd-stable@freebsd.org, Matt Simerson <freebsd@blockads.com>, Paul Herman <pherman@frenchfries.net> Subject: Re: bug in pw, -STABLE [patch] Message-ID: <20020623084607.H29729-100000@sea-incorporated.com> In-Reply-To: <20020623024804.GB95458@over-yonder.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 22 Jun 2002, Matthew D. Fuller wrote: > I looked at this, and there was something that I couldn't make work > (mentally, that is) with library functions that I could with a daemon, > but I've totally lost it. OK, let's see... Using a library does leave the door open for the following scenario, which ultimately stems from the fact that pids get reused: 1. a process p1 writes his pid in /var/run/file.pid 2. p1 dies a miserable death, leaving /var/run/file.pid intact 3. a long time passes, and nobody notices that p1 left a pid file 4. a new, unrelated process comes around with the same pid as p1 5. another process p2 wants /var/run/file.pid and finds that it exists and a process with the pid inside exists as well, except p2 has no way of knowing that the process has nothing to do with the pid file Actually, now that I think about it, even a daemon wouldn't guarantee better results in every such scenario. At first it would seem that the daemon would get a chance to clean up the pid file long before another process wanted it (during step 4). However, if the timing is just right then p1 can die the moment that its pid would be reused, and chances are that the daemon wouldn't catch it in time. > Now, this is a problem. There's a race condition here. It's a very > small window, to be sure, but I'm not quite sure how to close it. After I think you must've figured it out judging by your post that just came through as I was writing that previous paragraph. :) Geoff To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020623084607.H29729-100000>