Fix restart problem when the image file is removed.
authorPeng Huang <shawn.p.huang@gmail.com>
Wed, 26 May 2010 04:20:29 +0000 (12:20 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Wed, 26 May 2010 22:42:10 +0000 (06:42 +0800)
bus/ibusimpl.c

index 56e6ad5..17054f4 100644 (file)
@@ -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);
     }