Respawning reinitializes state
Casey Dahlin
cdahlin at redhat.com
Fri Oct 31 03:27:30 GMT 2008
Garrett Cooper wrote:
> Another item... When I do the following set of procedures,
> $COUNTER doesn't increment. Is that a bug or a possible feature by
> respawn not keeping state?
> Thanks!
> -Garrett
>
> [nova-cavium5:/etc/init/jobs.d]$ cat respawn_positive1
> respawn
> respawn limit 5 10000
>
> env COUNTER=0
>
> script
> touch /foo.$COUNTER
> let "COUNTER=$COUNTER+1"
> export COUNTER
> sleep 123456
> end script
> [nova-cavium5:/etc/init/jobs.d]$ start respawn_positive1
> [nova-cavium5:/etc/init/jobs.d]$ killall sleep
> [nova-cavium5:/etc/init/jobs.d]$ killall sleep
> [nova-cavium5:/etc/init/jobs.d]$ killall sleep
> [nova-cavium5:/etc/init/jobs.d]$ killall sleep
> [nova-cavium5:/etc/init/jobs.d]$ killall sleep
> [nova-cavium5:/etc/init/jobs.d]$ killall sleep
> [nova-cavium5:/etc/init/jobs.d]$ killall sleep
> [nova-cavium5:/etc/init/jobs.d]$ ls /foo.*
> /foo.0
> [nova-cavium5:/etc/init/jobs.d]$
>
>
That's the nature of environment variable behavior. Variables are copied
from parent process to child process at fork time, and vary
independently thereafter. We'd have to change posix to alter that behaviour.
--CJD
More information about the upstart-devel
mailing list