summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-06-16 18:47:20 +0100
committerBram Moolenaar <Bram@vim.org>2022-06-16 18:47:20 +0100
commitc72e31dfcc013ae840cd7f8899f2430b7f6812c9 (patch)
tree9c8aed4f3e53e7b224ad3849c55052ea744b11bd
parenta272624c763fea9f98510bbc5b1f2b65a309c765 (diff)
patch 8.2.5113: timer becomes invalid after fork/exec, :gui gives errorsv8.2.5113
Problem: Timer becomes invalid after fork/exec, :gui gives errors. (Gabriel Dupras) Solution: Delete the timer befor forking. (closes #10584)
-rw-r--r--src/gui.c5
-rw-r--r--src/os_unix.c15
-rw-r--r--src/proto/os_unix.pro1
-rw-r--r--src/version.c2
4 files changed, 22 insertions, 1 deletions
diff --git a/src/gui.c b/src/gui.c
index 68c64d298e..4408545db3 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -226,6 +226,11 @@ gui_do_fork(void)
int exit_status;
pid_t pid = -1;
+#if defined(FEAT_RELTIME) && defined(HAVE_TIMER_CREATE)
+ // a timer is not carried forward
+ delete_timer();
+#endif
+
// Setup a pipe between the child and the parent, so that the parent
// knows when the child has done the setsid() call and is allowed to
// exit.
diff --git a/src/os_unix.c b/src/os_unix.c
index 766deac9a8..6fd24508dd 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -8247,7 +8247,7 @@ xsmp_close(void)
#endif // USE_XSMP
#if defined(FEAT_RELTIME) || defined(PROTO)
-# if defined(HAVE_TIMER_CREATE)
+# if defined(HAVE_TIMER_CREATE) || defined(PROTO)
/*
* Implement timeout with timer_create() and timer_settime().
*/
@@ -8331,6 +8331,19 @@ start_timeout(long msec)
return &timeout_flag;
}
+/*
+ * To be used before fork/exec: delete any created timer.
+ */
+ void
+delete_timer(void)
+{
+ if (timer_created)
+ {
+ timer_delete(timer_id);
+ timer_created = FALSE;
+ }
+}
+
# else
/*
diff --git a/src/proto/os_unix.pro b/src/proto/os_unix.pro
index 91024b104c..268f3bfb65 100644
--- a/src/proto/os_unix.pro
+++ b/src/proto/os_unix.pro
@@ -88,4 +88,5 @@ void xsmp_init(void);
void xsmp_close(void);
void stop_timeout(void);
const int *start_timeout(long msec);
+void delete_timer(void);
/* vim: set ft=c : */
diff --git a/src/version.c b/src/version.c
index 66b03c3ab7..bfa9c5a263 100644
--- a/src/version.c
+++ b/src/version.c
@@ -735,6 +735,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 5113,
+/**/
5112,
/**/
5111,