Resolve empty message of forking when glib debug enabled
[platform/core/multimedia/mm-resource-manager.git] / src / daemon / mm_resource_manager_daemon.c
index 762f4ed..12b7782 100644 (file)
@@ -47,7 +47,7 @@ typedef enum {
 
 static GMainLoop *main_loop;
 static gboolean restart = FALSE;
-int notify_fd;
+int notify_fd[2];
 
 
 static gboolean fork_wait(void);
@@ -78,12 +78,12 @@ static gboolean fork_wait(void)
        MM_RM_RETVM_IF((pid = fork()) < 0, FALSE, "Daemon fork failed");
 
        if (pid != 0) {
-               close(fds[1]);
                /* Read in a string from the pipe */
                MM_RM_RETVM_IF(read(fds[0], msg, sizeof(msg)) < 0,
                        FALSE, "Failed to create pipe to get child status");
 
                close(fds[0]);
+               close(fds[1]);
 
                /* Parent process closes up output side of pipe */
                if (!strcmp(msg, MSG_DONE)) {
@@ -95,9 +95,8 @@ static gboolean fork_wait(void)
                }
        } else if (pid == 0) {
                /* Child process closes up input side of pipe */
-               close(fds[0]);
-
-               notify_fd = fds[1];
+               notify_fd[0] = fds[0];
+               notify_fd[1] = fds[1];
        }
 
        return TRUE;