- Timestamp:
- Sep 15, 2020, 9:44:11 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/shinstance.c
r3461 r3464 1507 1507 } 1508 1508 1509 /** 1510 * If we have a subshell status structure, signal and release it. 1511 */ 1512 static void shsubshellstatus_signal_and_release(shinstance *psh, int iExit) 1513 { 1514 shsubshellstatus *sts = psh->subshellstatus; 1515 if (sts) 1516 { 1517 BOOL rc; 1518 HANDLE hThread; 1519 1520 sts->status = W_EXITCODE(iExit, 0); 1521 sts->done = K_TRUE; 1522 rc = SetEvent((HANDLE)sts->towaiton); assert(rc); K_NOREF(rc); 1523 1524 hThread = (HANDLE)sts->hThread; 1525 sts->hThread = 0; 1526 rc = CloseHandle(hThread); assert(rc); 1527 1528 shsubshellstatus_release(psh, sts); 1529 psh->subshellstatus = NULL; 1530 } 1531 } 1532 1533 1509 1534 #endif /* !SH_FORKED_MODE */ 1510 1535 … … 1593 1618 shinstance * volatile volpsh = (shinstance *)user; 1594 1619 shinstance *psh = (shinstance *)user; 1595 shsubshellstatus *sts;1596 1620 struct jmploc exitjmp; 1597 1621 int iExit; … … 1625 1649 1626 1650 /* Signal parent. */ 1627 sts = psh->subshellstatus; 1628 if (sts) 1629 { 1630 BOOL rc; 1631 HANDLE hThread; 1632 1633 sts->status = W_EXITCODE(iExit, 0); 1634 sts->done = K_TRUE; 1635 rc = SetEvent((HANDLE)sts->towaiton); assert(rc); K_NOREF(rc); 1636 1637 hThread = (HANDLE)sts->hThread; 1638 sts->hThread = 0; 1639 rc = CloseHandle(hThread); assert(rc); 1640 1641 shsubshellstatus_release(psh, sts); 1642 psh->subshellstatus = NULL; 1643 } 1651 shsubshellstatus_signal_and_release(psh, iExit); 1644 1652 1645 1653 /* destroy the shell instance and exit the thread. */ … … 1842 1850 } 1843 1851 1844 SH_NORETURN_1 void sh__exit(shinstance *psh, int rc)1845 { 1846 TRACE2((psh, "sh__exit(%d)\n", rc));1852 SH_NORETURN_1 void sh__exit(shinstance *psh, int iExit) 1853 { 1854 TRACE2((psh, "sh__exit(%d)\n", iExit)); 1847 1855 1848 1856 #if defined(SH_FORKED_MODE) 1849 _exit( rc);1857 _exit(iExit); 1850 1858 (void)psh; 1851 1859 1852 1860 #else 1853 psh->exitstatus = rc;1861 psh->exitstatus = iExit; 1854 1862 1855 1863 /* … … 1858 1866 if (psh->thread) 1859 1867 { 1868 shsubshellstatus_signal_and_release(psh, iExit); 1860 1869 if (psh->exitjmp) 1861 longjmp(psh->exitjmp->loc, ! rc ? SH_EXIT_ZERO : rc);1870 longjmp(psh->exitjmp->loc, !iExit ? SH_EXIT_ZERO : iExit); 1862 1871 else 1863 1872 { 1864 1873 static char const s_msg[] = "fatal error in sh__exit: exitjmp is NULL!\n"; 1865 1874 shfile_write(&psh->fdtab, 2, s_msg, sizeof(s_msg) - 1); 1866 _exit( rc);1875 _exit(iExit); 1867 1876 } 1868 1877 } … … 1882 1891 } 1883 1892 1884 _exit( rc);1893 _exit(iExit); 1885 1894 #endif 1886 1895 } … … 2113 2122 { 2114 2123 #ifndef SH_FORKED_MODE 2115 /** @todo signal the end of this subshell now, we can do the cleaning up 2116 * after the parent shell has resumed. */ 2124 shsubshellstatus_signal_and_release(psh, (int)dwExitCode); 2117 2125 #endif 2118 2126 CloseHandle(ProcInfo.hProcess);
Note:
See TracChangeset
for help on using the changeset viewer.