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.