I am debugging a program that has a tendency to deadlock. On those occasions when it runs fine, ./program > log or ./program | tee log saves a copy of the output but if I do either of these, if the program deadlocks and I kill it with ^C (SIGINT) then the log is always empty. I know that the program has written something to stdout because that happens before the part where anything can get stuck and indeed when I just run ./program I see the output in the terminal.
I'd like a way to tee the output so that if I have to kill the program, the output so far is still saved in a log file. My shell is bash.
./program > log 2>&1– HBruijn Mar 03 '17 at 15:00set -min your script and usingtrapon caught signal. http://mywiki.wooledge.org/ProcessManagement – Valentin Bajrami Mar 03 '17 at 15:17