diff options
author | Peng Huang <shawn.p.huang@gmail.com> | 2009-02-27 13:46:06 +0800 |
---|---|---|
committer | Peng Huang <shawn.p.huang@gmail.com> | 2009-02-27 13:46:06 +0800 |
commit | be022f73729a0405d1bdba7fb3ef2549ff418977 (patch) | |
tree | 672949410c98d6d481d232d067b490a3bf8b9c19 | |
parent | 23c1bfcf064909af2075ebc02fc0772fb07a5a1f (diff) | |
download | ibus-be022f73729a0405d1bdba7fb3ef2549ff418977.tar.gz ibus-be022f73729a0405d1bdba7fb3ef2549ff418977.tar.xz ibus-be022f73729a0405d1bdba7fb3ef2549ff418977.zip |
Close all fds before restart
-rw-r--r-- | bus/ibusimpl.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/bus/ibusimpl.c b/bus/ibusimpl.c index f5e9794..479ce5d 100644 --- a/bus/ibusimpl.c +++ b/bus/ibusimpl.c @@ -1057,12 +1057,19 @@ _ibus_exit (BusIBusImpl *ibus, else { extern gchar **g_argv; gchar *exe; + gint fd; exe = g_strdup_printf ("/proc/%d/exe", getpid ()); if (!g_file_test (exe, G_FILE_TEST_EXISTS)) { g_free (exe); exe = g_argv[0]; } + + /* close all fds except stdin, stdout, stderr */ + for (fd = 3; fd <= sysconf (_SC_OPEN_MAX); fd ++) { + close (fd); + } + execv (exe, g_argv); g_warning ("execv %s failed!", g_argv[0]); exit (-1); |