agent: Remove dead code in REST JSON processing

Dead code found by Coverity.
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
agent: Don't spin CPU in the loop in this test

This test would otherwise just spin fast, instead of waiting
for a result in poll() or another blocking call.

Found by Coverity.
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Better handling of closing fds when execing

When spawning a new process double check that we can and have
closed all unnecessary file descriptors.

Issue found by coverity.
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>