aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-07-12 18:46:38 +0200
committerMattias Andrée <maandree@operamail.com>2015-07-12 18:46:38 +0200
commit238e49c7d88c55028591580ae1e7b62bf72967fe (patch)
treefd5912ba30d372f2860ae413bc8487043dd0247d /src/libmdsserver
parentindices (diff)
downloadmds-238e49c7d88c55028591580ae1e7b62bf72967fe.tar.gz
mds-238e49c7d88c55028591580ae1e7b62bf72967fe.tar.bz2
mds-238e49c7d88c55028591580ae1e7b62bf72967fe.tar.xz
fix race condition in prepare_reexec
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-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;