Use gmtime() instead of localtime() in debugging output to avoid lockups in signal handlers due to time zone lookups.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
### UNRELEASED
|
||||
|
||||
* fix: complete set of German translations supplied by Hartmut Goebel ([#98](https://codeberg.org/a-j-wood/pv/pulls/98))
|
||||
* fix: write UTC timestamps in debugging mode to avoid lockups in signal handlers
|
||||
* cleanup: removed TODO.md, since it's just an outdated copy of the issue tracker
|
||||
* cleanup: re-ordered structure members to reduce padding
|
||||
* cleanup: improved readability of SIGTTOU handling code
|
||||
|
||||
+11
-1
@@ -63,8 +63,18 @@ void debugging_output(const char *function, const char *file, int line, const ch
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note that here we use gmtime() rather than localtime(), otherwise
|
||||
* we can get stuck in signal handlers - testing with "strace"
|
||||
* showed many cases where "pv </dev/zero | cat >/dev/null" being
|
||||
* paused and backgrounded would cause pv to be stuck in
|
||||
* futex_wait() inside a pv_sig_alrm() inside a pv_sig_cont(). The
|
||||
* backtrace mentioned many time zone conversion steps, and all of
|
||||
* that goes away with gmtime().
|
||||
*/
|
||||
|
||||
(void) time(&t);
|
||||
tm = localtime(&t);
|
||||
tm = gmtime(&t);
|
||||
tbuf[0] = '\0';
|
||||
if (0 == strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", tm)) {
|
||||
tbuf[0] = '\0';
|
||||
|
||||
Reference in New Issue
Block a user