On Thu, Aug 03, 2000 at 01:37:19PM +1200, Chris Cameron wrote:
> On Thursday, August 03, 2000 11:57 AM, Laird Nelson 
> [SMTP:[EMAIL PROTECTED]] wrote:
> > That is, the fact that I'm seeing nothing grabbing a pid inbetween the
> > fork and exec calls doesn't mean that something COULDN'T grab a PID at
> > that point.  SO I really shouldn't rely on the delta being 3 at all,
> > should I.

Absolutely not!  Even if this were reliable, it would still be
highly fragile.  It would break if a new version of CVS added or
deleted a process.  It would even break if you changed your
commitinfo or verifymsg to invoke any subprocesses.

> Then again, if this is Linux, I don't know how similar to the 
> commercial flavours of Unix it is in this regard.

Similar enough.  fork() and exec() are still distinct system
calls; the user-space code between them is still a critical
section.


On Wed, Aug 02, 2000 at 07:18:16PM -0400, Laird Nelson wrote:
> Doesn't a fork and exec result in...two addi...

...tional PIDs?  No, just one.

> aha, but the second cvs
> (the one that's exec'ed) is then invoking my loginfo script so that's
> why loginfo getppid() returns commitinfo.getppid() + 3.

Perhaps it's like this:

                  Original-cvs=1000
                         |
        +----------------+------------------+
        |                |                  |
  commitinfo=1001   verifymsg=1002    child-cvs=1003
                                            |
                                        loginfo=1004

with processes 1000 and 1003 being the ones seen by the various
getppid() calls.  But perhaps that's what you meant all along...

Anything that depends on counting PIDs is unsafe; anything that
depends on parsing ps(1) output is unportable; any of these is
pointless if CVS moves to a different algorithm for generating
the temp-dir name (eg. if it starts using mktemp(3)).


On Thu, Aug 03, 2000 at 12:17:50AM -0400, Donald Sharp wrote:
> Have a control file that tracks directory names based on the
> original cvs invocation pid.

Why not make the original cvs (pid 1000 in my example) export the
temp-dir name into an environment variable?  The variable would
be scoped correctly, by definition.  And there would be no
reliance on PIDs.

--

|  | /\
|-_|/  >   Eric Siegerman, Toronto, Ont.        [EMAIL PROTECTED]
|  |  /
[Microsoft's] www.hotmail.com is running Apache/1.3.6 (Unix) ... on FreeBSD 
        - Netcraft's "What's that site running?" service, 12-Jun-2000

Reply via email to