annotate stdio_catcher @ 20:c7ea49d19055

Import library(debug) explicitly; removed spurious \n from debug messages.
author samer
date Thu, 09 Feb 2012 11:16:36 +0000
parents e0a1f92fcbc9
children
rev   line source
samer@18 1 #!/bin/sh
samer@18 2 echo "In stdio_catcher"
samer@18 3
samer@18 4 function handle_term {
samer@18 5 echo "### $(date): received SIGTERM" >> "$outputlog"
samer@18 6 exit
samer@18 7 }
samer@18 8
samer@18 9 function handle_int {
samer@18 10 echo "### $(date): received SIGINT" >> "$outputlog"
samer@18 11 }
samer@18 12
samer@18 13 function handle_hup {
samer@18 14 echo "### $(date): received SIGHUP" >> "$outputlog"
samer@18 15 exit
samer@18 16 }
samer@18 17
samer@18 18 trap handle_int 2
samer@18 19 trap handle_term 15
samer@18 20 trap handle_hup 1
samer@18 21
samer@18 22 inputlog="$1"
samer@18 23 outputlog="$2"
samer@18 24 shift 2
samer@18 25
samer@18 26 echo "### $(date): INPUT - $@" >> "$inputlog"
samer@18 27 echo "### $(date): OUTPUT - $@" >> "$outputlog"
samer@18 28 nohup tee -a "$inputlog" | "$@" | nohup tee -a "$outputlog"
samer@18 29 #"$@"