summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-03-26 22:43:07 +0000
committerLennart Poettering <lennart@poettering.net>2008-03-26 22:43:07 +0000
commit0ba9852be34baeb654914d6995cfd4d4641bcb77 (patch)
tree33c658a5fae845a7090633a1377b5644d260e8ad /examples
parent3ff2f54d8ecaa1cacfbfddc61daeda1bcee8dfec (diff)
fix a gcc warning
git-svn-id: file:///home/lennart/svn/public/libdaemon/trunk@137 153bfa13-eec0-0310-be40-b0cb6a0e1b4b
Diffstat (limited to 'examples')
-rw-r--r--examples/testd.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/examples/testd.c b/examples/testd.c
index ffdd4ce..c8f5b52 100644
--- a/examples/testd.c
+++ b/examples/testd.c
@@ -44,11 +44,11 @@ int main(int argc, char *argv[]) {
int ret;
/* Kill daemon with SIGINT */
-
+
/* Check if the new function daemon_pid_file_kill_wait() is available, if it is, use it. */
if ((ret = daemon_pid_file_kill_wait(SIGINT, 5)) < 0)
daemon_log(LOG_WARNING, "Failed to kill daemon");
-
+
return ret < 0 ? 1 : 0;
}
@@ -56,7 +56,7 @@ int main(int argc, char *argv[]) {
if ((pid = daemon_pid_file_is_running()) >= 0) {
daemon_log(LOG_ERR, "Daemon already running on PID file %u", pid);
return 1;
-
+
}
/* Prepare for return value passing from the initialization procedure of the daemon process */
@@ -68,7 +68,7 @@ int main(int argc, char *argv[]) {
/* Exit on error */
daemon_retval_done();
return 1;
-
+
} else if (pid) { /* The parent */
int ret;
@@ -80,7 +80,7 @@ int main(int argc, char *argv[]) {
daemon_log(ret != 0 ? LOG_ERR : LOG_INFO, "Daemon returned %i as return value.", ret);
return ret;
-
+
} else { /* The daemon */
int fd, quit = 0;
fd_set fds;
@@ -89,7 +89,7 @@ int main(int argc, char *argv[]) {
daemon_log(LOG_ERR, "Failed to close all file descriptors: %s", strerror(errno));
goto finish;
}
-
+
/* Create the PID file */
if (daemon_pid_file_create() < 0) {
daemon_log(LOG_ERR, "Could not create PID file (%s).", strerror(errno));
@@ -105,7 +105,7 @@ int main(int argc, char *argv[]) {
daemon_retval_send(2);
goto finish;
}
-
+
/*... do some further init work here */
@@ -117,8 +117,9 @@ int main(int argc, char *argv[]) {
/* Prepare for select() on the signal fd */
FD_ZERO(&fds);
- FD_SET(fd = daemon_signal_fd(), &fds);
-
+ fd = daemon_signal_fd();
+ FD_SET(fd, &fds);
+
while (!quit) {
fd_set fds2 = fds;
@@ -128,7 +129,7 @@ int main(int argc, char *argv[]) {
/* If we've been interrupted by an incoming signal, continue */
if (errno == EINTR)
continue;
-
+
daemon_log(LOG_ERR, "select(): %s", strerror(errno));
break;
}
@@ -168,7 +169,7 @@ finish:
daemon_retval_send(-1);
daemon_signal_done();
daemon_pid_file_remove();
-
+
return 0;
}
}