summaryrefslogtreecommitdiff
path: root/lib/daemon.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-07-08 17:14:44 -0400
committerH. Peter Anvin <hpa@zytor.com>2008-07-08 17:14:44 -0400
commit22accddda0b5a47cb2f6ace54a359e102c31ec02 (patch)
tree5704229813beaa717bce4fb06d46d510dd03fa1f /lib/daemon.c
parent62533e74411a579e5d24e33b50c5ba750b88ae35 (diff)
downloadtftp-hpa-22accddda0b5a47cb2f6ace54a359e102c31ec02.tar.gz
Reformat the source code
The source code was a mix of different styles; normalize on NASM style; basically K&R style with 4 space indentation.
Diffstat (limited to 'lib/daemon.c')
-rw-r--r--lib/daemon.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/lib/daemon.c b/lib/daemon.c
index c3106b5..0eb39c9 100644
--- a/lib/daemon.c
+++ b/lib/daemon.c
@@ -6,32 +6,31 @@
int daemon(int nochdir, int noclose)
{
- int nullfd;
- pid_t f;
-
- if (!nochdir) {
- if (chdir("/"))
- return -1;
- }
+ int nullfd;
+ pid_t f;
- if (!noclose) {
- if ((nullfd = open("/dev/null", O_RDWR)) < 0 ||
- dup2(nullfd, 0) < 0 ||
- dup2(nullfd, 1) < 0 ||
- dup2(nullfd, 2) < 0)
- return -1;
- close(nullfd);
- }
+ if (!nochdir) {
+ if (chdir("/"))
+ return -1;
+ }
- f = fork();
- if (f < 0)
- return -1;
- else if (f > 0)
- _exit(0);
+ if (!noclose) {
+ if ((nullfd = open("/dev/null", O_RDWR)) < 0 ||
+ dup2(nullfd, 0) < 0 ||
+ dup2(nullfd, 1) < 0 || dup2(nullfd, 2) < 0)
+ return -1;
+ close(nullfd);
+ }
+
+ f = fork();
+ if (f < 0)
+ return -1;
+ else if (f > 0)
+ _exit(0);
#ifdef HAVE_SETSID
- return setsid();
+ return setsid();
#else
- return 0;
+ return 0;
#endif
}