bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AIX and Interix also do early PID recycling.


From: Greg Wooledge
Subject: Re: AIX and Interix also do early PID recycling.
Date: Tue, 24 Jul 2012 11:49:05 -0400
User-agent: Mutt/1.4.2.3i

On Tue, Jul 24, 2012 at 05:03:36PM +0200, michael.haubenwallner@salomon.at 
wrote:
> Description:
>       On AIX (5.3, 6.1, 7.1), as well as on Interix (any version) I do 
> encounter
>       some race condition in a code similar to:
>           if grep "unwanted" /some/nonexistent/filename
>           then
>             echo "bad"
>             exit 1
>           fi
>           echo "good"
>       Sometimes it does "bad" while it should do "good" always.

If that happens, then I don't see how it is related to recyling PIDs.
In fact, if grep is failing to produce the correct result, it it a
problem with your OS's implementation of grep, and not with bash.

>                 [[ ${#last} > 4 ]] && used=used_${last::((${#last}-4))} || 
> used=used_0

That [[ ${#last} > 4 ]] check is incorrect.  You're doing a string
comparison there; [[ 10 > 4 ]] is false.  Either use ((...)) or use -gt.

In any case, if your script breaks because PIDs are recycled sooner than
you expect, then it is a bug in your script, and not in bash.  (What
would you expect bash to do about it in the first place?)  It may also
interest you to know that there are some operating systems that use
random PID allocation, instead of sequential (OpenBSD for example).

http://mywiki.wooledge.org/ProcessManagement has some tips on how to
deal with multiple processes.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]