Kill entire process group upon exit; Make pid and log files configurable

Also unbuffer stdout and stderr; mkdir -p log and pid files