From 2925f5072d540bcd258d9a8f0317cc1ea5b4de5b Mon Sep 17 00:00:00 2001 From: Botond Baranyi <botond.baranyi@ericsson.com> Date: Wed, 18 Dec 2019 13:44:53 +0100 Subject: [PATCH] Fixed HC crash on docker (bug 558427) Change-Id: I1351ae3146a7f389ca3752f7f3fba1751a95e598 Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com> --- core/Logger.cc | 5 +++++ core/Runtime.cc | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/Logger.cc b/core/Logger.cc index 17d5c74d5..241f48b12 100644 --- a/core/Logger.cc +++ b/core/Logger.cc @@ -458,6 +458,11 @@ char *TTCN_Logger::mputstr_timestamp(char *str, time_t tv_sec = tv->tv_sec; struct tm *lt = localtime(&tv_sec); if (lt == NULL) fatal_error("localtime() call failed."); + if (errno != 0) { + // HACK: 'localtime' may set the 'errno' on some systems (even though it + // succeeds); make sure this doesn't affect other code + errno = 0; + } if (p_timestamp_format == TIMESTAMP_TIME) { str = mputprintf(str, "%02d:%02d:%02d.%06ld", lt->tm_hour, lt->tm_min, lt->tm_sec, tv->tv_usec); diff --git a/core/Runtime.cc b/core/Runtime.cc index a466d5cb9..8b8a95fd1 100644 --- a/core/Runtime.cc +++ b/core/Runtime.cc @@ -3019,7 +3019,6 @@ void TTCN_Runtime::wait_terminated_processes() // this function might be called from TCs too while returning from // TTCN_Communication::process_all_messages_hc() after fork() if (!is_hc()) return; - errno = 0; for ( ; ; ) { int statuscode; #ifdef __clang__ @@ -3028,6 +3027,7 @@ void TTCN_Runtime::wait_terminated_processes() struct rusage r_usage = {{0,0},{0,0},0,0,0,0,0,0,0,0,0,0,0,0,0,0}; #endif + errno = 0; #ifdef INTERIX pid_t child_pid = waitpid(-1, &statuscode, WNOHANG); getrusage(RUSAGE_CHILDREN, &r_usage); -- GitLab