aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libmdsserver/util.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libmdsserver/util.c b/src/libmdsserver/util.c
index 8af7b10..c5aee89 100644
--- a/src/libmdsserver/util.c
+++ b/src/libmdsserver/util.c
@@ -106,6 +106,10 @@ int prepare_reexec(void)
fail_if (len < 0);
/* ‘readlink() does not append a null byte to buf.’ */
self_exe[len] = '\0';
+ /* Handle possible race condition: file was removed. */
+ if (access(self_exe, F_OK) < 0)
+ if (!strcmp(self_exe + (len - 10), " (deleted)"))
+ self_exe[len - 10] = '\0';
return 0;
fail:
return -1;