Move close_all_fds right before exec 63/91663/2
authorMichal Bloch <m.bloch@samsung.com>
Mon, 10 Oct 2016 15:12:00 +0000 (17:12 +0200)
committerMichal Bloch <m.bloch@samsung.com>
Mon, 10 Oct 2016 16:20:10 +0000 (09:20 -0700)
Some FDs (specifically, the ones used for dlog logging)
are in use between current close_all_fds call spot and exec

Change-Id: Ie64fad2cef350c2e2931da6a3c21200471b23fdb
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
src/launchpad.c

index e573ea3..a0c8a8b 100755 (executable)
@@ -489,6 +489,7 @@ static int __normal_fork_exec(int argc, char **argv)
                setenv("LD_LIBRARY_PATH", libdir, 1);
        free(libdir);
 
+       _close_all_fds();
        if (execv(argv[LOADER_ARG_PATH], argv) < 0) { /* Flawfinder: ignore */
                if (errno == EACCES) {
                        _E("such a file is no executable - %s",
@@ -587,7 +588,6 @@ static int __exec_app_process(void *arg)
        __signal_unblock_sigchld();
        __signal_fini();
 
-       _close_all_fds();
        _delete_sock_path(getpid(), getuid());
 
        PERF("prepare exec - first done");