summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang Peng <shawn.p.huang@gmail.com>2009-03-02 13:13:09 +0800
committerHuang Peng <shawn.p.huang@gmail.com>2009-03-02 13:13:09 +0800
commit9c00f8f1d762db1cd61dd1a758e587df6c7dde96 (patch)
tree034c7cfac113db8af1486046d76542f1cf888064
parente1c8775b084f3c5080e185a94d0e41f185526eba (diff)
downloadibus-9c00f8f1d762db1cd61dd1a758e587df6c7dde96.tar.gz
ibus-9c00f8f1d762db1cd61dd1a758e587df6c7dde96.tar.xz
ibus-9c00f8f1d762db1cd61dd1a758e587df6c7dde96.zip
Refine coding style.
-rw-r--r--bus/main.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/bus/main.c b/bus/main.c
index 13b13cc..cc4507e 100644
--- a/bus/main.c
+++ b/bus/main.c
@@ -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