Skip to content

Commit c72e31d

Browse files
committed
patch 8.2.5113: timer becomes invalid after fork/exec, :gui gives errors
Problem: Timer becomes invalid after fork/exec, :gui gives errors. (Gabriel Dupras) Solution: Delete the timer befor forking. (closes #10584)
1 parent a272624 commit c72e31d

4 files changed

Lines changed: 22 additions & 1 deletion

File tree

src/gui.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ gui_do_fork(void)
226226
int exit_status;
227227
pid_t pid = -1;
228228

229+
#if defined(FEAT_RELTIME) && defined(HAVE_TIMER_CREATE)
230+
// a timer is not carried forward
231+
delete_timer();
232+
#endif
233+
229234
// Setup a pipe between the child and the parent, so that the parent
230235
// knows when the child has done the setsid() call and is allowed to
231236
// exit.

src/os_unix.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8247,7 +8247,7 @@ xsmp_close(void)
82478247
#endif // USE_XSMP
82488248

82498249
#if defined(FEAT_RELTIME) || defined(PROTO)
8250-
# if defined(HAVE_TIMER_CREATE)
8250+
# if defined(HAVE_TIMER_CREATE) || defined(PROTO)
82518251
/*
82528252
* Implement timeout with timer_create() and timer_settime().
82538253
*/
@@ -8331,6 +8331,19 @@ start_timeout(long msec)
83318331
return &timeout_flag;
83328332
}
83338333

8334+
/*
8335+
* To be used before fork/exec: delete any created timer.
8336+
*/
8337+
void
8338+
delete_timer(void)
8339+
{
8340+
if (timer_created)
8341+
{
8342+
timer_delete(timer_id);
8343+
timer_created = FALSE;
8344+
}
8345+
}
8346+
83348347
# else
83358348

83368349
/*

src/proto/os_unix.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,5 @@ void xsmp_init(void);
8888
void xsmp_close(void);
8989
void stop_timeout(void);
9090
const int *start_timeout(long msec);
91+
void delete_timer(void);
9192
/* vim: set ft=c : */

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
5113,
737739
/**/
738740
5112,
739741
/**/

0 commit comments

Comments
 (0)