Author: abd4lla
Date: 2009-08-05 05:45:45 +0000 (Wed, 05 Aug 2009)
New Revision: 7
Added:
include/fired.h
src/fired.c
Modified:
src/CMakeLists.txt
tests/CMakeLists.txt
Log:
Added initial daemon files, code stub only
Added: include/fired.h
===================================================================
--- include/fired.h (rev 0)
+++ include/fired.h 2009-08-05 05:45:45 UTC (rev 7)
@@ -0,0 +1,34 @@
+// Author: Abd4llA "Ahmed Abdalla" <abd4lla(a)fedoraproject.org>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Library General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// Copyright 2009 Abd4llA
+
+#ifndef FIRED_H
+#define FIRED_H
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <syslog.h>
+#include <string.h>
+
+
+int32_t fired_init_daemon(void);
+int32_t fired_register_to_dbus(void);
+
+#endif
Modified: src/CMakeLists.txt
===================================================================
--- src/CMakeLists.txt 2009-08-04 13:10:58 UTC (rev 6)
+++ src/CMakeLists.txt 2009-08-05 05:45:45 UTC (rev 7)
@@ -1 +1,2 @@
+ADD_EXECUTABLE(fired fired.c)
ADD_LIBRARY(fkiptc fkiptc.c)
Added: src/fired.c
===================================================================
--- src/fired.c (rev 0)
+++ src/fired.c 2009-08-05 05:45:45 UTC (rev 7)
@@ -0,0 +1,76 @@
+// Author: Abd4llA "Ahmed Abdalla" <abd4lla(a)fedoraproject.org>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Library General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// Copyright 2009 Abd4llA
+#include "fired.h"
+int main(void) {
+
+ /* Our process ID and Session ID */
+ pid_t pid, sid;
+
+ /* Fork off the parent process */
+ pid = fork();
+ if (pid < 0) {
+ exit(EXIT_FAILURE);
+ }
+ /* If we got a good PID, then
+ * we can exit the parent process. */
+ if (pid > 0) {
+ exit(EXIT_SUCCESS);
+ }
+
+ /* Change the file mode mask */
+ umask(0);
+
+ /* Open any logs here */
+
+ /* Create a new SID for the child process */
+ sid = setsid();
+ if (sid < 0) {
+ /* Log the failure */
+ exit(EXIT_FAILURE);
+ }
+
+
+
+ /* Change the current working directory */
+ if ((chdir("/")) < 0) {
+ /* Log the failure */
+ exit(EXIT_FAILURE);
+ }
+
+ /* Close out the standard file descriptors */
+ close(STDIN_FILENO);
+ close(STDOUT_FILENO);
+ close(STDERR_FILENO);
+
+ int32_t logFile = open("/tmp/fired.log",O_RDWR | O_CREAT);
+ if (logFile < 0){
+ exit(EXIT_FAILURE);
+ }
+
+ char * msg = "Registering to dbus\n";
+
+ /* Register ourselves to dbus daemon */
+ //register_to_dbus();
+
+ /* The Big Loop */
+ while (1) {
+ /* Do some task here ... */
+ write(logFile, msg, strlen(msg));
+ sleep(30); /* wait 30 seconds */
+ }
+ exit(EXIT_SUCCESS);
+}
Modified: tests/CMakeLists.txt
===================================================================
--- tests/CMakeLists.txt 2009-08-04 13:10:58 UTC (rev 6)
+++ tests/CMakeLists.txt 2009-08-05 05:45:45 UTC (rev 7)
@@ -1,2 +1,2 @@
-ADD_EXECUTABLE(fkiptc-test1 fkiptc-test1.c)
-TARGET_LINK_LIBRARIES(fkiptc-test1 fkiptc)
+#ADD_EXECUTABLE(fkiptc-test1 fkiptc-test1.c)
+#TARGET_LINK_LIBRARIES(fkiptc-test1 fkiptc)
Show replies by date