From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:49773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUH4k-0003Le-L3 for qemu-devel@nongnu.org; Fri, 02 Nov 2012 09:14:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TUH4j-0007pB-Oo for qemu-devel@nongnu.org; Fri, 02 Nov 2012 09:14:18 -0400 Received: from mail-ea0-f173.google.com ([209.85.215.173]:40968) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUH4j-0007np-J9 for qemu-devel@nongnu.org; Fri, 02 Nov 2012 09:14:17 -0400 Received: by mail-ea0-f173.google.com with SMTP id a1so1421427eaa.4 for ; Fri, 02 Nov 2012 06:14:17 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 2 Nov 2012 14:14:05 +0100 Message-Id: <1351862047-23172-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1351862047-23172-1-git-send-email-pbonzini@redhat.com> References: <1351862047-23172-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 3/5] qemu-timer: reinitialize timers after fork List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: blauwirbel@gmail.com, jan.kiszka@siemens.com, peter.maydell@linaro.org Timers are not inherited by the child of a fork(2), so just use pthread_atfork to reinstate them after daemonize. Signed-off-by: Paolo Bonzini --- qemu-timer.c | 15 ++++++++++++++- 1 file modificato, 14 inserzioni(+). 1 rimozione(-) diff --git a/qemu-timer.c b/qemu-timer.c index f3426c9..1d87694 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -742,6 +742,17 @@ static void quit_timers(void) t->stop(t); } +static void reinit_timers(void) +{ + struct qemu_alarm_timer *t = alarm_timer; + t->stop(t); + if (t->start(t)) { + fprintf(stderr, "Internal timer error: aborting\n"); + exit(1); + } + qemu_rearm_alarm_timer(t); +} + int init_timer_alarm(void) { struct qemu_alarm_timer *t = NULL; @@ -765,6 +776,9 @@ int init_timer_alarm(void) } atexit(quit_timers); +#ifdef CONFIG_POSIX + pthread_atfork(NULL, NULL, reinit_timers); +#endif alarm_timer = t; return 0; -- 1.7.12.1