summaryrefslogtreecommitdiffhomepage
path: root/src/daemon.c
diff options
context:
space:
mode:
authorMukund Sivaraman <muks@banu.com>2009-09-15 01:11:25 +0530
committerMukund Sivaraman <muks@banu.com>2009-09-15 01:11:25 +0530
commit7b9234f394b688991a5b601ff1e487a19de29870 (patch)
treeccdb923e457666c174311bdf0f2ca4370e27e70c /src/daemon.c
parent2cb677759236fe54c24c1ce099a61f54bace3f73 (diff)
Indent code to Tinyproxy coding style
The modified files were indented with GNU indent using the following command: indent -npro -kr -i8 -ts8 -sob -l80 -ss -cs -cp1 -bs -nlps -nprs -pcs \ -saf -sai -saw -sc -cdw -ce -nut -il0 No other changes of any sort were made.
Diffstat (limited to 'src/daemon.c')
-rw-r--r--src/daemon.c63
1 files changed, 29 insertions, 34 deletions
diff --git a/src/daemon.c b/src/daemon.c
index 17d41b5..9a87d7a 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -29,29 +29,28 @@
* Fork a child process and then kill the parent so make the calling
* program a daemon process.
*/
-void
-makedaemon (void)
+void makedaemon (void)
{
- if (fork () != 0)
- exit (0);
+ if (fork () != 0)
+ exit (0);
- setsid ();
- set_signal_handler (SIGHUP, SIG_IGN);
+ setsid ();
+ set_signal_handler (SIGHUP, SIG_IGN);
- if (fork () != 0)
- exit (0);
+ if (fork () != 0)
+ exit (0);
- chdir ("/");
- umask (0177);
+ chdir ("/");
+ umask (0177);
#if NDEBUG
- /*
- * When not in debugging mode, close the standard file
- * descriptors.
- */
- close (0);
- close (1);
- close (2);
+ /*
+ * When not in debugging mode, close the standard file
+ * descriptors.
+ */
+ close (0);
+ close (1);
+ close (2);
#endif
}
@@ -59,29 +58,25 @@ makedaemon (void)
* Pass a signal number and a signal handling function into this function
* to handle signals sent to the process.
*/
-signal_func *
-set_signal_handler (int signo, signal_func * func)
+signal_func *set_signal_handler (int signo, signal_func * func)
{
- struct sigaction act, oact;
+ struct sigaction act, oact;
- act.sa_handler = func;
- sigemptyset (&act.sa_mask);
- act.sa_flags = 0;
- if (signo == SIGALRM)
- {
+ act.sa_handler = func;
+ sigemptyset (&act.sa_mask);
+ act.sa_flags = 0;
+ if (signo == SIGALRM) {
#ifdef SA_INTERRUPT
- act.sa_flags |= SA_INTERRUPT; /* SunOS 4.x */
+ act.sa_flags |= SA_INTERRUPT; /* SunOS 4.x */
#endif
- }
- else
- {
+ } else {
#ifdef SA_RESTART
- act.sa_flags |= SA_RESTART; /* SVR4, 4.4BSD */
+ act.sa_flags |= SA_RESTART; /* SVR4, 4.4BSD */
#endif
- }
+ }
- if (sigaction (signo, &act, &oact) < 0)
- return SIG_ERR;
+ if (sigaction (signo, &act, &oact) < 0)
+ return SIG_ERR;
- return oact.sa_handler;
+ return oact.sa_handler;
}