From 7912b45a0526f78467098b36022adfb203d587b0 Mon Sep 17 00:00:00 2001 From: Peng Huang Date: Wed, 26 May 2010 12:20:29 +0800 Subject: [PATCH] Fix restart problem when the image file is removed. --- bus/ibusimpl.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bus/ibusimpl.c b/bus/ibusimpl.c index 56e6ad5..17054f4 100644 --- a/bus/ibusimpl.c +++ b/bus/ibusimpl.c @@ -1316,6 +1316,15 @@ _ibus_exit (BusIBusImpl *ibus, } execv (exe, g_argv); + + /* If the server binary is replaced while the server is running, + * "readlink /proc/[pid]/exe" might return a path with " (deleted)" + * suffix. */ + const gchar suffix[] = " (deleted)"; + if (g_str_has_suffix (exe, suffix)) { + exe [strlen (exe) - strlen (suffix)] = '\0'; + execv (exe, g_argv); + } g_warning ("execv %s failed!", g_argv[0]); exit (-1); } -- 2.7.4