check_procs: Add delay after forking in test (#1272)

Mikael Falkvidd notifications at github.com
Thu Jul 10 21:17:14 CEST 2014


Forking raises a race condition, where the parent might run the
test before the child has had time to fork. If that happens,
an error similar to this is produced:
 Failed test 'Output correct'
 at ./t/check_procs.t line 32.
                 'PROCS OK: 0 processes with args 'sleep 7' | processes=0;;;0;'
   doesn't match '/^PROCS OK: 1 process?/'

Sleeping a bit should avoid the problem. It might be enough to
sleep less than a second, but perl's built-in sleep function only
supports integer seconds.

In our build environment, the build failed 3 of 4 times before
this patch. After the patch it failed 0 of 7 times.

Signed-off-by: Mikael Falkvidd <mfalkvidd at op5.com>
You can merge this Pull Request by running:

  git pull https://github.com/mfalkvidd/monitoring-plugins master

Or you can view, comment on it, or merge it online at:

  https://github.com/monitoring-plugins/monitoring-plugins/pull/1272

-- Commit Summary --

  * check_procs: Add delay after forking in test

-- File Changes --

    M plugins/t/check_procs.t (2)

-- Patch Links --

https://github.com/monitoring-plugins/monitoring-plugins/pull/1272.patch
https://github.com/monitoring-plugins/monitoring-plugins/pull/1272.diff

-- 
Reply to this email on GitHub:
https://github.com/monitoring-plugins/monitoring-plugins/pull/1272
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20140710/ce78ccfe/attachment.html>


More information about the Devel mailing list