17667 - run() call in an agent can return incorrect Process::Status

Previously the guard thread used in the #shell class would cause a race
condition when it tried to reap the pid before the process was finished
executing which led to systemu setting the wrong value to $$.

We now only try to reap the pid in the thread spawned by systemu if the
parent thread is dead and the subprocess created by systemu is still
around. This should remove the race condition that causes Shell to
return incorrect return codes and also avoid the creation of zombie
processes.