From 155e6d080b57b968f853b0076ea3de0f24f4975d Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Tue, 13 Nov 2007 17:44:08 +0100 Subject: [PATCH] Fix setitimer implementation to register only one cleanup with atexit. Signed-off-by: Johannes Sixt --- compat/mingw.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compat/mingw.c b/compat/mingw.c index 63c632adaf..9b503a0eec 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -679,6 +679,7 @@ static inline int is_timeval_eq(const struct timeval *i1, const struct timeval * int setitimer(int type, struct itimerval *in, struct itimerval *out) { static const struct timeval zero; + static int atexit_done; if (out != NULL) return errno = EINVAL, @@ -697,7 +698,10 @@ int setitimer(int type, struct itimerval *in, struct itimerval *out) timer_interval = in->it_interval.tv_sec * 1000 + in->it_interval.tv_usec / 1000; one_shot = is_timeval_eq(&in->it_value, &zero); - atexit(stop_timer_thread); + if (!atexit_done) { + atexit(stop_timer_thread); + atexit_done = 1; + } return start_timer_thread(); }