redirect stdout stderr to launch_app
authorGwangho Hwang <gwang.hwang@samsung.com>
Thu, 11 Jul 2013 07:34:50 +0000 (16:34 +0900)
committerGwangho Hwang <gwang.hwang@samsung.com>
Thu, 11 Jul 2013 07:34:50 +0000 (16:34 +0900)
Change-Id: I39f5c1cbfd9877ff74c705299b60ce13a12942d0
Signed-off-by: Gwangho Hwang <gwang.hwang@samsung.com>
packaging/debug-launchpad.spec
src/launchpad.c

index da02ef9..c555448 100644 (file)
@@ -1,6 +1,6 @@
 Name:       debug-launchpad
 Summary:    Debug Launchpad
-Version:    0.0.5
+Version:    0.0.6
 Release:    1
 Group:      System Environment/Daemons
 License:    Apache License, Version 2.0
index 0ec7be1..9d6f27b 100755 (executable)
@@ -976,6 +976,38 @@ void __waiting_outputfile()
        return;
 }
 
+int __stdout_stderr_redirection(int defpid)
+{
+       char defpath[UNIX_PATH_MAX];
+       int deffd, result=0; 
+
+       /* stdout */
+       snprintf(defpath, UNIX_PATH_MAX, "/proc/%d/fd/1", defpid);
+       deffd = open(defpath,O_WRONLY);
+       if(deffd < 0) {
+               _E("opening caller(%d) stdout failed due to %s"
+                       , defpid, strerror(errno));
+               result++;
+       }else{
+               dup2(deffd, 1);
+               close(deffd);
+       }
+
+       /* stderr */
+       snprintf(defpath, UNIX_PATH_MAX, "/proc/%d/fd/2", defpid);
+       deffd = open(defpath,O_WRONLY);
+       if(deffd < 0) {
+               _E("opening caller(%d) stderr failed due to %s"
+                       , defpid,strerror(errno));
+               result+=2;
+       }else{
+               dup2(deffd, 2);
+               close(deffd);
+       }
+
+       return result;
+}
+
 void __launchpad_main_loop(int main_fd)
 {
        bundle *kb = NULL;
@@ -1056,6 +1088,10 @@ void __launchpad_main_loop(int main_fd)
                        , getpid());
                unlink(sock_path);
 
+               if(__stdout_stderr_redirection(__get_caller_pid(kb))) {
+                       _E("__stdout_stderr_redirection fail");
+               }
+
                PERF("prepare exec - first done");
                _D("lock up test log(no error) : prepare exec - first done");