diff options
author | Huang Peng <shawn.p.huang@gmail.com> | 2009-03-02 13:13:09 +0800 |
---|---|---|
committer | Huang Peng <shawn.p.huang@gmail.com> | 2009-03-02 13:13:09 +0800 |
commit | 9c00f8f1d762db1cd61dd1a758e587df6c7dde96 (patch) | |
tree | 034c7cfac113db8af1486046d76542f1cf888064 /bus/main.c | |
parent | e1c8775b084f3c5080e185a94d0e41f185526eba (diff) | |
download | ibus-9c00f8f1d762db1cd61dd1a758e587df6c7dde96.tar.gz ibus-9c00f8f1d762db1cd61dd1a758e587df6c7dde96.tar.xz ibus-9c00f8f1d762db1cd61dd1a758e587df6c7dde96.zip |
Refine coding style.
Diffstat (limited to 'bus/main.c')
-rw-r--r-- | bus/main.c | 27 |
1 files changed, 14 insertions, 13 deletions
@@ -90,43 +90,44 @@ execute_cmdline (const gchar *cmdline) } #ifndef HAVE_DAEMON -void closeall(int fd) +static void +closeall (gint fd) { - int fdlimit = sysconf(_SC_OPEN_MAX); + gint fdlimit = sysconf(_SC_OPEN_MAX); - while (fd < fdlimit) + while (fd < fdlimit) { close(fd++); + } } -int daemon(int nochdir, int noclose) +static gint +daemon (gint nochdir, gint noclose) { - switch (fork()) - { + switch (fork()) { case 0: break; case -1: return -1; default: _exit(0); } - if (setsid() < 0) + if (setsid() < 0) { return -1; + } - switch (fork()) - { + switch (fork()) { case 0: break; case -1: return -1; default: _exit(0); } - if (!nochdir) + if (!nochdir) { chdir("/"); + } - if (!noclose) - { + if (!noclose) { closeall(0); open("/dev/null",O_RDWR); dup(0); dup(0); } - return 0; } #endif |