Simplify monitor loop and terminate correctly on signal

Refactored the monitor loop in the timeout and terminating
signal cases.
When receiving a terminating signal, the monitored processes
will receive the user defined signal instead of the received
terminating signal itself. This is more consistent and avoids
the issue of SIGINT not caught by background processes when
receiving a keyboard interrupt.
When sending the termination signal to all processes in
timeout or signal condition, the signal is sent only once
for each process.
Use the python logging facility and added a --log-file option.
Added tests for termination on signal and tests for detached processes.