VirtualBox

Changeset 3441 in kBuild


Ignore:
Timestamp:
Sep 10, 2020 11:54:53 AM (5 years ago)
Author:
bird
Message:

kash: sh_getenv loop-for-ever fix. sh_exec threaded-mode fix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/shinstance.c

    r3439 r3441  
    6767*   Global Variables                                                                                                             *
    6868*********************************************************************************************************************************/
     69#ifndef SH_FORKED_MODE
     70/** Mutex serializing exec/spawn to prevent unwanted file inherting. */
     71static shmtx        g_sh_exec_mtx;
     72#endif
    6973/** The mutex protecting the the globals and some shell instance members (sigs). */
    7074static shmtx        g_sh_mtx;
     
    640644    assert(g_sh_mtx.au64[SHMTX_MAGIC_IDX] != SHMTX_MAGIC);
    641645    shmtx_init(&g_sh_mtx);
     646#ifndef SH_FORKED_MODE
     647    shmtx_init(&g_sh_exec_mtx);
     648#endif
    642649
    643650    psh = sh_create_shell_common(argv, envp, NULL /*parentfdtab*/);
     
    785792            &&  item[len] == '=')
    786793            return (char *)item + len + 1;
     794        i++;
    787795    }
    788796
     
    16501658        shfile_uninit(&psh->fdtab);
    16511659        sh_int_unlink(psh);
     1660        /** @todo    */
    16521661    }
    16531662
     
    16981707         * This ain't quite straight forward on Windows...
    16991708         */
     1709#ifndef SH_FORKED_MODE
     1710        shmtxtmp tmp;
     1711#endif
    17001712        PROCESS_INFORMATION ProcInfo;
    17011713        STARTUPINFO StrtInfo;
     
    18091821
    18101822        /* File handles. */
     1823#ifndef SH_FORKED_MODE
     1824        shmtx_enter(&g_sh_exec_mtx, &tmp);
     1825#endif
    18111826        StrtInfo.dwFlags   |= STARTF_USESTDHANDLES;
    18121827        StrtInfo.lpReserved2 = shfile_exec_win(&psh->fdtab, 1 /* prepare */, &StrtInfo.cbReserved2, hndls);
     
    18161831
    18171832        /* Get going... */
    1818         if (CreateProcess(exe,
    1819                           cmdline,
    1820                           NULL,         /* pProcessAttributes */
    1821                           NULL,         /* pThreadAttributes */
    1822                           TRUE,         /* bInheritHandles */
    1823                           0,            /* dwCreationFlags */
    1824                           envblock,
    1825                           cwd,
    1826                           &StrtInfo,
    1827                           &ProcInfo))
     1833        rc = CreateProcess(exe,
     1834                           cmdline,
     1835                           NULL,         /* pProcessAttributes */
     1836                           NULL,         /* pThreadAttributes */
     1837                           TRUE,         /* bInheritHandles */
     1838                           0,            /* dwCreationFlags */
     1839                           envblock,
     1840                           cwd,
     1841                           &StrtInfo,
     1842                           &ProcInfo);
     1843
     1844        shfile_exec_win(&psh->fdtab, 0 /* done */, NULL, NULL);
     1845#ifndef SH_FORKED_MODE
     1846        shmtx_leave(&g_sh_exec_mtx, &tmp);
     1847#endif
     1848        if (rc)
    18281849        {
    18291850            DWORD dwErr;
     
    18371858            {
    18381859                CloseHandle(ProcInfo.hProcess);
    1839                 _exit(dwExitCode);
     1860                sh__exit(psh, dwExitCode);
    18401861            }
     1862            TRACE2((psh, "sh_execve: GetExitCodeProcess failed: %u\n", GetLastError()));
     1863            assert(0);
     1864            CloseHandle(ProcInfo.hProcess);
    18411865            errno = EINVAL;
    18421866        }
     
    18571881        }
    18581882
    1859         shfile_exec_win(&psh->fdtab, 0 /* done */, NULL, NULL);
    18601883    }
    18611884    rc = -1;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette