Wait socket creation for stdout & stderr redirection 70/81870/4
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 29 Jul 2016 03:46:55 +0000 (12:46 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 29 Jul 2016 04:12:17 +0000 (13:12 +0900)
Change-Id: I18ec250046dca0a64446ca5828649f699277d1c0
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/debug-launchpad.c

index 30d5385..f1a872c 100644 (file)
@@ -63,6 +63,8 @@ static int __real_send(int clifd, int ret)
 static void __send_result_to_caller(int clifd, int ret)
 {
        int res;
+       int count = 0;
+       char path[PATH_MAX];
 
        _W("Check app launching");
 
@@ -75,6 +77,20 @@ static void __send_result_to_caller(int clifd, int ret)
                return;
        }
 
+       snprintf(path, sizeof(path), "/run/aul/apps/%d/%d/.app-sock",
+                       getuid(), ret);
+       _D("socket path: %s", path);
+       do {
+               if (access(path, F_OK) == 0) {
+                       _D("%s exists", path);
+                       break;
+               }
+
+               _D("-- now wait socket creation --");
+               usleep(50 * 1000);
+               count++;
+       } while (count < 20);
+
        res = _proc_check_cmdline_bypid(ret);
        if (res < 0) {
                _E("The app process might be terminated "
@@ -264,15 +280,15 @@ static int __start_process(const char *appid, const char *app_path,
                PERF("fork done");
                _D("lock up test log(no error): fork done");
 
+               if (__stdout_stderr_redirection(__get_caller_pid(kb)))
+                       _E("__stdout_stderr_redirection() failed");
+
                _signal_unblock_sigchld();
                _signal_fini();
 
                _close_all_fds();
                _delete_sock_path(getpid(), getuid());
 
-               if (__stdout_stderr_redirection(__get_caller_pid(kb)))
-                       _E("__stdout_stderr_redirection() failed");
-
                PERF("prepare exec - fisrt done");
                _D("lock up test log(no error): prepare exec - first done");