summaryrefslogtreecommitdiff
path: root/src/miav_daemon.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/miav_daemon.cc')
-rw-r--r--src/miav_daemon.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/miav_daemon.cc b/src/miav_daemon.cc
index 633ab7d..2d679c3 100644
--- a/src/miav_daemon.cc
+++ b/src/miav_daemon.cc
@@ -31,6 +31,9 @@
/*
* $Log$
+ * Revision 1.2 2005/06/14 12:29:40 deva
+ * Incorporated the use of the Info object everywhere... also using the log functionality.
+ *
* Revision 1.1 2005/06/09 11:00:03 deva
* Added daemon code, and cleaned up using -Wall and -Werror
*
@@ -45,6 +48,9 @@
#include "server.h"
#include "socket.h"
+#include <signal.h>
+#include <errno.h>
+
MiavDaemon::MiavDaemon()
{}
@@ -53,7 +59,8 @@ MiavDaemon::~MiavDaemon()
int MiavDaemon::daemon_main()
{
- InfoConsole info;
+ MiavConfig cfg(ETC"/miav.conf", NULL);
+ InfoConsole info(&cfg);
config = new MiavConfig(ETC"/miav.conf", &info);
int port = config->readInt("server_port");
@@ -62,7 +69,7 @@ int MiavDaemon::daemon_main()
signal(SIGCLD, SIG_IGN); // Ved SIGCHILD til IGNORE maa wait/waitpid ikke kaldes
// (ellers kommer der kernel-brok)
- printf("Listening on port %d\n", port);
+ info.log("Listening on port %d", port);
Socket *socket = new Socket(port, &info);
while(1) {
@@ -72,11 +79,11 @@ int MiavDaemon::daemon_main()
switch(childpid) {
case -1: // fork() returns -1 on failure
- perror("fork");
+ info.log("Fork error: %s", strerror(errno));
exit(1);
case 0: // fork() returns 0 to the child process
delete socket; // Close listen socket.
- newConnection(csocket);
+ newConnection(csocket, &info);
delete csocket; // Close communication socket.
exit(0);