fix app terminate fail issue in TaskManager
authorMooChang Kim <moochang.kim@samsung.com>
Thu, 10 Oct 2013 05:51:31 +0000 (14:51 +0900)
committerMooChang Kim <moochang.kim@samsung.com>
Thu, 10 Oct 2013 05:57:31 +0000 (14:57 +0900)
cause : when app termiate, TaskManager receives gdbserver pid instead of app pid
solution : send app pid instead of gdbserver pid in gdbserver launching case.

Change-Id: I46f78d438340b3100ee5f3a001ec118185df43a6
Signed-off-by: MooChang Kim <moochang.kim@samsung.com>
src/launchpad.c
src/sigchild.h

index f85437d..b5334df 100755 (executable)
@@ -111,6 +111,7 @@ static char *launchpad_cmdline;
 static int initialized = 0;
 
 static int poll_outputfile = 0;
+static int is_gdbserver_launched;
 
 void __set_oom();
 void __set_env(app_info_from_db * menu_info, bundle * kb);
@@ -1005,6 +1006,10 @@ int __prepare_fork(bundle *kb, char *appid)
        }
        if(str_array == NULL) return 0;
 
+       is_gdbserver_launched = 0;
+       gdbserver_pid = -1;
+       gdbserver_app_pid = -1;
+
        for (i = 0; i < len; i++) {
                if(str_array[i] == NULL) break;
                /* gdbserver */
@@ -1025,6 +1030,7 @@ int __prepare_fork(bundle *kb, char *appid)
                        }
                        __adjust_file_capability(PATH_GDBSERVER);
                        need_to_set_inh_cap_after_fork++;
+                       is_gdbserver_launched++;
                }
                /* valgrind */
                else if (strncmp(str_array[i], SDK_VALGRIND
@@ -1231,6 +1237,21 @@ void __launchpad_main_loop(int main_fd)
                exit(-1);
        }
 
+       if(is_gdbserver_launched) {
+               char buf[MAX_LOCAL_BUFSZ];
+
+               usleep(100 * 1000);     /* 100ms sleep */
+               snprintf(buf, MAX_LOCAL_BUFSZ, "%s.exe", app_path);
+               gdbserver_app_pid = __proc_iter_cmdline(NULL, buf);
+
+               if(gdbserver_app_pid == -1) {
+                       _E("faild to get app pid");
+               } else {
+                       gdbserver_pid = pid;
+                       pid = gdbserver_app_pid;
+               }
+       }
+
        _D("==> real launch pid : %d %s\n", pid, app_path);
        is_real_launch = 1;
 
index 8aa3238..85824bc 100755 (executable)
@@ -26,6 +26,8 @@
 static struct sigaction old_sigchild;
 static DBusConnection *bus = NULL;
 sigset_t oldmask;
+static int gdbserver_pid;
+static int gdbserver_app_pid;
 
 static inline void __socket_garbage_collector()
 {
@@ -123,6 +125,10 @@ static int __sigchild_action(void *data)
        if (dead_pid <= 0)
                goto end;
 
+       /* send app pid instead of gdbserver pid */
+       if(dead_pid == gdbserver_pid)
+               dead_pid = gdbserver_app_pid;
+
        __send_app_dead_signal(dead_pid);
 
        snprintf(buf, MAX_LOCAL_BUFSZ, "%s/%d", AUL_SOCK_PREFIX, dead_pid);