Remove daemonization 53/171553/2
authorPaweł Szewczyk <p.szewczyk@samsung.com>
Mon, 5 Mar 2018 11:59:54 +0000 (12:59 +0100)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Wed, 7 Mar 2018 19:17:59 +0000 (20:17 +0100)
It's not necessary to fork the daemon manually, we have systemd for
managing that. The forking also may affect the sd_listen_ api.

Change-Id: Ia067e64a31787ee87f1b150959765aff40e9d007
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
packaging/sdbd.service
packaging/sdbd_device.service
packaging/sdbd_device_tv.service
packaging/sdbd_emulator.service
packaging/sdbd_emulator_tv.service
packaging/sdbd_tcp.service
src/sdb.c

index 8f65db9..eb49efe 100644 (file)
@@ -4,7 +4,7 @@ Description=sdbd
 [Service]
 #If necessary, Put Environment variable settings in a file like below
 #ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf"
-Type=forking
+Type=simple
 PIDFile=/tmp/.sdbd.pid
 RemainAfterExit=yes
 ExecStart=/usr/sbin/sdbd
index 38851a8..080e0ed 100644 (file)
@@ -6,7 +6,7 @@ After=tmp.mount
 [Service]
 User=sdk
 Group=sdk
-Type=forking
+Type=simple
 #location of SDBD log file
 #If necessary, Put Environment variable settings in a file like below
 #ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf"
index 416c818..88d3a08 100644 (file)
@@ -4,7 +4,7 @@ Requires=tizen-system-env.service
 After=tmp.mount
 
 [Service]
-Type=forking
+Type=simple
 #location of SDBD log file
 #Environment=SDBD_LOG_PATH=/tmp
 #If necessary, Put Environment variable settings in a file like below
index e6a4d3e..9b87f40 100644 (file)
@@ -7,7 +7,7 @@ After=tmp.mount dbus.service
 [Service]
 User=sdk
 Group=sdk
-Type=forking
+Type=simple
 Environment=DISPLAY=:0
 PIDFile=/tmp/.sdbd.pid
 RemainAfterExit=yes
index 634974c..3dc42e3 100644 (file)
@@ -5,7 +5,7 @@ After=tmp.mount dbus.service
 #DefaultDependencies=false
 
 [Service]
-Type=forking
+Type=simple
 #location of SDBD log file
 #Environment=SDBD_LOG_PATH=/tmp
 #If necessary, Put Environment variable settings in a file like below
index 7ff330d..6871f29 100644 (file)
@@ -5,7 +5,7 @@ After=default.target
 [Service]
 User=sdk
 Group=sdk
-Type=forking
+Type=simple
 Environment=DISPLAY=:0
 #If necessary, Put Environment variable settings in a file like below
 #ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf"
index 079d9fc..0cd265b 100644 (file)
--- a/src/sdb.c
+++ b/src/sdb.c
@@ -1225,43 +1225,6 @@ void start_device_log(void)
     sdb_close(fd);
 }
 
-int daemonize(void) {
-
-    // set file creation mask to 0
-    umask(0);
-
-    switch (fork()) {
-    case -1:
-        return -1;
-    case 0:
-        break;
-    default:
-        _exit(0);
-    }
-#ifdef SDB_PIDPATH
-    char* tmppath = NULL;
-    tmppath = realpath(SDB_PIDPATH, NULL);
-    if (tmppath == NULL && errno == ENOENT) {
-        FILE *f = fopen(SDB_PIDPATH, "w");
-
-        if (f != NULL) {
-            fprintf(f, "%d\n", getpid());
-            fclose(f);
-        }
-    } else {
-        D("sdbd: %s file is existed. It might not work properly.\n", SDB_PIDPATH);
-        free(tmppath);
-    }
-#endif
-    if (setsid() == -1)
-        return -1;
-
-    if (chdir("/") < 0)
-        D("sdbd: unable to change working directory to /\n");
-
-    return 0;
-}
-
 /* Constructs a local name of form tcp:port.
  * target_str points to the target string, it's content will be overwritten.
  * target_size is the capacity of the target string.
@@ -2302,9 +2265,6 @@ int main(int argc, char **argv)
         return EXIT_FAILURE;
     }
 
-    if (daemonize() < 0)
-        fatal("daemonize() failed: errno:%d", errno);
-
     D("Handling main()\n");
 
     //sdbd will never die on emulator!