When we write log, flush output buffers in a few more cases
I observed a case when signal delivery message was buffered
by stdio until it was flushed along with the next syscall
entry message.
* strace.c (trace): Flush output buffers in a few more cases.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
diff --git a/strace.c b/strace.c
index 910a11c..ed7d641 100644
--- a/strace.c
+++ b/strace.c
@@ -2462,6 +2462,7 @@
#endif
printtrailer();
}
+ fflush(tcp->outf);
droptcb(tcp);
continue;
}
@@ -2479,6 +2480,7 @@
tprintf("+++ exited with %d +++", WEXITSTATUS(status));
printtrailer();
}
+ fflush(tcp->outf);
droptcb(tcp);
continue;
}
@@ -2580,6 +2582,7 @@
signame(sig)
PC_FORMAT_ARG);
printtrailer();
+ fflush(tcp->outf);
}
goto restart_tracee;
}
@@ -2606,6 +2609,7 @@
tcp_last->flags |= TCB_REPRINT;
tprints(" <unfinished ...>");
printtrailer();
+ fflush(tcp->outf);
}
/* We assume that ptrace error was caused by process death.
* We used to detach(tcp) here, but since we no longer