Export command variable assignments to the environment.

In the POSIX sh language, variable assignments preceding a command are
exported to the enviroment of the command. Previously runcmd_open() was
not handling this for simple commands that don't require a subshell to
run (the shell handles this for more complex commands that we run in a
subshell).

These changes export the variable assignments without requiring a
complete subshell.
runcmd: Handle child errors more thoroughly and uniformly.

runcmd_open() was not detecting some error conditions that would result
in the child runtime environment not being established correctly. With
the exception of close(), calls in the newly created child process that
can fail within reason are now checked and reported to stderr before
exiting.
runcmd: Correct comments and cleanup some code.

Corrected comments regarding 'async-safety', code attribution, and code
function. runcmd_init() is definitely NOT reentrant, and incorrectly
calling this function as if it were would invalidate the reentrancy of
the other functions that access the pids global variable.

Moved Doxygen section end (/** @} */) in runcmd.h inside include guard
in order to not confuse Doxygen. Removed unused and incorrect SIG_ERR
define, and one declaration per line.
runcmd: Improve error handling & memory management.

runcmd_cmd2strv():
Check for valid arguments, test for failed allocation, and
null-terminate the output argv array. Also avoid a potential leak if
returning early on unexpected end of string (really shouldn't ever
happen).

runcmd_open():
Check all arguments are non-null: __attribute__((__nonnull__(1, 2, 3, 5,
6))) is not a guarantee, it is still perfectly possible to pass NULL in
the specified positions and not pass "-Wnonnull" to gcc, or just ignore
the warning if it is generated. Handle failed allocation from
runcmd_cmd2strv(), consider commands with unbalanced quotes an error
(the shell does), and return the correct error code if pipe(pfd) fails.

test-runcmd:
Free our allocated memory. The only unfreed memory is now the pids array
internal to runcmd.c.
Fixed a bug calling killproc_nagios() from stop
Using TERM as suggested in the comment here: https://github.com/NagiosEnterprises/nagioscore/pull/6#discussion_r14309447
Remove unused killproc_nagios() arg, and pass signal name with -s.
Put nagios.configtest in Nagios' var dir.

The file isn't strictly related to the system run state, and it may be
useful to preserve the last configuration errors across reboots.
Checks: Reimplement auto rescheduling.

adjust_check_scheduling() is intended to smooth out load by more evenly
scheduling checks, but wasn't updated to work with the new heap based
scheduling queue.

These changes closely replicate the original implementation while using
the new data structures reasonably efficiently, and providing
sub-second resolution when calculating new event run times.

The rescheduling algorithm makes some assumptions about per-check
overhead that may be overly pessimistic, and possibly not needed to
generate a smooth schedule. When rescheduled, the next run of an event
may be earlier or later than dictated by its check interval, but will
run at its regular check interval when no schedule adjustment is
needed.
Checks: Increase minimum spacing for auto-reschedulinng.

The projected check overhead determines the how close check events can
be without trigger an auto-reshcedule. Increase from 1/16th to 1/8th
seconds to keep schedules smoother. This should ideally be determined
dynamically based on configured checks.
wproc: Make wproc_reap() behave as advertised.

Although only called when checking if an event should be run when job
control is enabled, this function did not behave as advertised.
Additionally waiting up to 3 seconds to reap 100 jobs may be excessive,
especially when fewer than 100 jobs are running. We'll wait up to one
millisecond for one job instead.
Check events: More accurately determine if auto-rescheduling is needed.

Previously we were looking at timed_event.run_time which has second
precision. This would cause rescheduling to be run only when events
occured in the same second.

By looking at squeue_event.when we get the actual run times used by the
event scheduling priority queue with microsecond precision.
Init script: Set variables before sourcing sysconfig.

Doing this after setting the variables allows sysconfig settings to
override the configure/install-time defaults.
Init script: Whitespace and formatting cleanup.
Check events: Don't estimate exec. time in auto-rescheduling.

Estimates of check execution time weren't too sophisticated or uniform
(we only have real measurments for host checks). By removing these
estimates the algirithm is simpler and the new schedule is smoother.

Also use cheduling_info.service_inter_check_delay/4 as a threshold for
determining if check events are too close in time and need to be
rescheduled. This removes hardcoded thresholds and makes the
rescheduling criteria dependent on the acutal configured checks.
Merge branch 'master' of github.com:NagiosEnterprises/nagioscore into emislivec-scheduling
Init script: Don't try to start if already running.

Running start with an instance of nagios already running would result
in the running instance's command pipe being removed. Test that the
lock file does not hold the PID of a running process before attempting
to start a new instance.

Also remove some unused arguments from status_nagios calls.
Init script: Quote kill's signal specification.

This gives a little bit less confusing error message if someone were to
invoke killproc_nagios without specifying a signal to send.
wproc: Correctly calculate remaining time to wait in wproc_reap().
test-runcmd: Fix missing-field-initializers

I'm not quite clear on exactly why I can't get my fedora-gcc to complain
about this, but travis' ubuntu-gcc seems to complain.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>