Kaydet (Commit) 4e1ba939 authored tarafından Suleyman Poyraz's avatar Suleyman Poyraz

Daemon bazlı hata var. Ancak --daemon parametresi eklendi.

üst a294df87
......@@ -76,6 +76,7 @@ extern int config_debug;
extern int config_print;
extern int config_runlevel;
extern int config_ignore_missing;
extern int config_daemon;
extern char *config_dir_models;
extern char *config_dir_modules;
......
/*
*
* Copyright (c) 2019, Ali Rıza Keskin
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
......@@ -46,7 +72,7 @@ static void skeleton_daemon()
/* Change the working directory to the root directory */
/* or another appropriated directory */
chdir("/");
chdir("/"); //FIXME: Try it for problems
/* Close all open file descriptors */
int x;
......
......@@ -86,6 +86,9 @@ int config_print = 0;
//! Runlevel (1 after logging enabled)
int config_runlevel = 0;
//! Daemon mode (1 after daemon mode enabled)
int config_daemon = 0;
//! Ignore missing functions
int config_ignore_missing = 0;
......@@ -97,6 +100,7 @@ static struct option longopts[] = {
{ "ignore-missing", 0, NULL, 'i' },
{ "logdir", required_argument, NULL, 'l' },
{ "print", 0, NULL, 'p' },
{ "daemon", 0, NULL, 'q' },
{ "socket", required_argument, NULL, 's' },
{ "timeout", required_argument, NULL, 't' },
{ "help", 0, NULL, 'h' },
......
......@@ -188,6 +188,7 @@ handle_core_message(DBusMessage *bus_msg, const char *path, const char *iface, c
}
bus_reply_object(bus_msg, py_list, "as");
}
// TODO: add some new features
}
static DBusHandlerResult
......@@ -215,9 +216,11 @@ filter_func(DBusConnection *conn, DBusMessage *bus_msg, void *data)
log_debug("Got message '%s.%s' from '%s'\n", iface, method, sender);
if (strcmp(config_interface, iface) == 0 && strcmp(path, "/") == 0) {
// "setLocale" and "cancel" methods are handled in main process
// TODO: Öncekine giden yol
if (strcmp(method, "setLocale") == 0 || strcmp(method, "cancel") == 0 || strcmp(method, "listRunning") == 0) {
handle_core_message(bus_msg, path, iface, method, sender, py_args);
}
else {
// Else, handle in child process
proc_fork(handle_message, bus_msg);
......
......@@ -30,7 +30,7 @@
#include "process.h"
#include "script.h"
#include "utils.h"
#include "daemon.c"
#include "daemon.h"
#include <stdio.h>
#include <stdlib.h>
......@@ -82,7 +82,10 @@ main(int argc, char *argv[])
proc_init();
// Daemon start
skeleton_daemon();
if (config_daemon == 1) {
skeleton_daemon();
}
// Enter main loop
loop_exec();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment