1812 Use #stop for a hard-suspend, which is not affected by interrupts. |
1812 Use #stop for a hard-suspend, which is not affected by interrupts. |
1813 Should be called with interrupts disabled." |
1813 Should be called with interrupts disabled." |
1814 |
1814 |
1815 suspendSemaphore notNil ifTrue:[suspendSemaphore signalForAll]. |
1815 suspendSemaphore notNil ifTrue:[suspendSemaphore signalForAll]. |
1816 suspendActions notNil ifTrue:[ |
1816 suspendActions notNil ifTrue:[ |
1817 |savedState| |
1817 |savedState| |
1818 |
1818 |
1819 savedState := state. |
1819 savedState := state. |
1820 state := #aboutToSuspend. |
1820 state := #aboutToSuspend. |
1821 suspendActions do:[:action | action value]. |
1821 suspendActions do:[:action | action value]. |
1822 state ~~ #aboutToSuspend ifTrue:[ |
1822 state ~~ #aboutToSuspend ifTrue:[ |
1823 "/ mhmh - one of the suspendActions lead to making me active again; |
1823 "/ mhmh - one of the suspendActions lead to making me active again; |
1824 "/ bail out. |
1824 "/ bail out. |
1825 "/ This fixes the Semaphore was signalled, but process did not run error, |
1825 "/ This fixes the Semaphore was signalled, but process did not run error, |
1826 "/ which can happen when a process with a suspend action goes into a readWait, |
1826 "/ which can happen when a process with a suspend action goes into a readWait, |
1827 "/ and the suspend action does a thread switch, and the readWait semaphore gets |
1827 "/ and the suspend action does a thread switch, and the readWait semaphore gets |
1828 "/ signalled before we come back here. Then the semaphore wakeup will have already |
1828 "/ signalled before we come back here. Then the semaphore wakeup will have already |
1829 "/ place me back into the run state, so I should not go into a suspend below. |
1829 "/ place me back into the run state, so I should not go into a suspend below. |
1830 ^ self. |
1830 ^ self. |
1831 ]. |
1831 ]. |
1832 state := savedState. |
1832 state := savedState. |
1833 ]. |
1833 ]. |
1834 |
1834 |
1835 " |
1835 " |
1836 this is a bit of a kludge: allow someone else to |
1836 this is a bit of a kludge: allow someone else to |
1837 set the state to something like #ioWait etc. |
1837 set the state to something like #ioWait etc. |
1838 In this case, do not set the receivers state to #suspend. |
1838 In this case, do not set the receiver's state to #suspend. |
1839 (All of this to enhance the output of the process monitor ...) |
1839 (All of this to enhance the output of the process monitor ...) |
1840 " |
1840 " |
1841 (state == #active |
1841 (state == #active |
1842 or:[state == #run |
1842 or:[state == #run |
1843 or:[aStateSymbol == #stopped]]) ifTrue:[ |
1843 or:[aStateSymbol == #stopped]]) ifTrue:[ |
1844 state := aStateSymbol. |
1844 state := aStateSymbol. |
1845 ]. |
1845 ]. |
1846 Processor suspend:self |
1846 Processor suspend:self |
1847 ! |
1847 ! |
1848 |
1848 |
1849 terminate |
1849 terminate |
1906 |
1906 |
1907 "Modified: / 24.8.1998 / 18:29:46 / cg" |
1907 "Modified: / 24.8.1998 / 18:29:46 / cg" |
1908 ! |
1908 ! |
1909 |
1909 |
1910 terminateAllGUISubprocesses |
1910 terminateAllGUISubprocesses |
1911 "terminate all the receivers gui subprocesses and their children as well |
1911 "terminate all the receiver's gui subprocesses and their children as well |
1912 (i.e. all processes which are offsprings of the receiver, except for |
1912 (i.e. all processes which are offsprings of the receiver, except for |
1913 the receiver itself)." |
1913 the receiver itself)." |
1914 |
1914 |
1915 id isNil ifTrue:[ |
1915 id isNil ifTrue:[ |
1916 "/ problem: |
1916 "/ problem: |
1917 "/ if receiver is already dead, its id is nil. |
1917 "/ if receiver is already dead, its id is nil. |
1918 "/ children are found by looking for processes with a parentID identical to |
1918 "/ children are found by looking for processes with a parentID identical to |
1919 "/ mine - ifNil, system processes are found, which is probably not what you |
1919 "/ mine - ifNil, system processes are found, which is probably not what you |
1920 "/ want ... |
1920 "/ want ... |
1921 "/ FIX: remember the id (or dont nil it when terminating) |
1921 "/ FIX: remember the id (or dont nil it when terminating) |
1922 "/ requires VM changes. |
1922 "/ requires VM changes. |
1923 ProcessorScheduler invalidProcessSignal |
1923 ProcessorScheduler invalidProcessSignal |
1924 raiseRequestWith:self |
1924 raiseRequestWith:self |
1925 errorString:'process is already dead - cannot determine child processes'. |
1925 errorString:'process is already dead - cannot determine child processes'. |
1926 ^ self |
1926 ^ self |
1927 ]. |
1927 ]. |
1928 ProcessorScheduler knownProcesses do:[:aProcess | |
1928 ProcessorScheduler knownProcesses do:[:aProcess | |
1929 aProcess ~~ self ifTrue:[ |
1929 aProcess ~~ self ifTrue:[ |
1930 aProcess creatorId == id ifTrue:[ |
1930 aProcess creatorId == id ifTrue:[ |
1931 aProcess isGUIProcess ifTrue:[ |
1931 aProcess isGUIProcess ifTrue:[ |
1932 aProcess terminateWithAllGUISubprocesses |
1932 aProcess terminateWithAllGUISubprocesses |
1933 ] |
1933 ] |
1934 ] |
1934 ] |
1935 ] |
1935 ] |
1936 ]. |
1936 ]. |
1937 |
1937 |
1938 "Created: / 28-10-1996 / 20:43:32 / cg" |
1938 "Created: / 28-10-1996 / 20:43:32 / cg" |
1939 "Modified: / 26-10-2012 / 13:16:35 / cg" |
1939 "Modified: / 26-10-2012 / 13:16:35 / cg" |
1940 ! |
1940 ! |
1941 |
1941 |
1942 terminateAllSubprocessesInGroup |
1942 terminateAllSubprocessesInGroup |
1943 "terminate all subprocesses which have the receiver process as groupID, |
1943 "terminate all subprocesses which have the receiver process as groupID, |
1944 and their group-children as well. |
1944 and their group-children as well. |
1945 (i.e. all processes in the receivers process group, except for the receiver itself, |
1945 (i.e. all processes in the receiver's process group, except for the receiver itself, |
1946 and recursively oll of their group processes.)." |
1946 and recursively oll of their group processes.)." |
1947 |
1947 |
1948 id isNil ifTrue:[ |
1948 id isNil ifTrue:[ |
1949 "/ problem: |
1949 "/ problem: |
1950 "/ if receiver is already dead, its id is nil. |
1950 "/ if receiver is already dead, its id is nil. |
1951 "/ children are found by looking for processes with a parentID identical to |
1951 "/ children are found by looking for processes with a parentID identical to |
1952 "/ mine - ifNil, system processes are found, which is probably not what you |
1952 "/ mine - ifNil, system processes are found, which is probably not what you |
1953 "/ want ... |
1953 "/ want ... |
1954 "/ FIX: remember the id (or dont nil it when terminating) |
1954 "/ FIX: remember the id (or dont nil it when terminating) |
1955 "/ requires VM changes. |
1955 "/ requires VM changes. |
1956 ProcessorScheduler invalidProcessSignal |
1956 ProcessorScheduler invalidProcessSignal |
1957 raiseRequestWith:self |
1957 raiseRequestWith:self |
1958 errorString:'process is already dead - cannot determine child processes'. |
1958 errorString:'process is already dead - cannot determine child processes'. |
1959 ^ self |
1959 ^ self |
1960 ]. |
1960 ]. |
1961 self terminateAllSubprocessesInGroup:id |
1961 self terminateAllSubprocessesInGroup:id |
1962 ! |
1962 ! |
1963 |
1963 |
1964 terminateAllSubprocessesInGroup:aGroup |
1964 terminateAllSubprocessesInGroup:aGroup |
1965 "terminate all subprocesses which have aGroup as groupID, |
1965 "terminate all subprocesses which have aGroup as groupID, |
1966 and their group-children as well. |
1966 and their group-children as well. |
1967 (i.e. all processes in the receivers process group, except for the receiver itself, |
1967 (i.e. all processes in the receiver's process group, except for the receiver itself, |
1968 and recursively oll of their group processes.)." |
1968 and recursively oll of their group processes.)." |
1969 |
1969 |
1970 ProcessorScheduler knownProcesses do:[:aProcess | |
1970 ProcessorScheduler knownProcesses do:[:aProcess | |
1971 aProcess ~~ self ifTrue:[ |
1971 aProcess ~~ self ifTrue:[ |
1972 (aProcess processGroupId == aGroup) ifTrue:[ |
1972 (aProcess processGroupId == aGroup) ifTrue:[ |
1973 aProcess terminateWithAllSubprocessesInGroup |
1973 aProcess terminateWithAllSubprocessesInGroup |
1974 ] |
1974 ] |
1975 ] |
1975 ] |
1976 ]. |
1976 ]. |
1977 |
1977 |
1978 "Created: / 28.10.1996 / 20:43:32 / cg" |
1978 "Created: / 28.10.1996 / 20:43:32 / cg" |
1979 "Modified: / 3.11.1997 / 00:28:06 / cg" |
1979 "Modified: / 3.11.1997 / 00:28:06 / cg" |
1980 ! |
1980 ! |
1981 |
1981 |
1982 terminateGroup |
1982 terminateGroup |
1983 "terminate the receiver with all of its created subprocesses |
1983 "terminate the receiver with all of its created subprocesses |
1984 that are in the receivers process group." |
1984 that are in the receiver's process group." |
1985 |
1985 |
1986 id isNil ifTrue:[ |
1986 id isNil ifTrue:[ |
1987 "/ problem: |
1987 "/ problem: |
1988 "/ if receiver is already dead, its id is nil. |
1988 "/ if receiver is already dead, its id is nil. |
1989 "/ children are found by looking for processes with a parentID identical to |
1989 "/ children are found by looking for processes with a parentID identical to |
1990 "/ mine - ifNil, system processes are found, which is probably not what you |
1990 "/ mine - ifNil, system processes are found, which is probably not what you |
1991 "/ want ... |
1991 "/ want ... |
1992 "/ FIX: remember the id (or dont nil it when terminating) |
1992 "/ FIX: remember the id (or dont nil it when terminating) |
1993 "/ requires VM changes. |
1993 "/ requires VM changes. |
1994 ProcessorScheduler invalidProcessSignal |
1994 ProcessorScheduler invalidProcessSignal |
1995 raiseRequestWith:self |
1995 raiseRequestWith:self |
1996 errorString:'process is already dead - cannot determine child processes'. |
1996 errorString:'process is already dead - cannot determine child processes'. |
1997 ^ self |
1997 ^ self |
1998 ]. |
1998 ]. |
1999 ProcessorScheduler knownProcesses do:[:aProcess | |
1999 ProcessorScheduler knownProcesses do:[:aProcess | |
2000 aProcess ~~ self ifTrue:[ |
2000 aProcess ~~ self ifTrue:[ |
2001 aProcess processGroupId == id ifTrue:[ |
2001 aProcess processGroupId == id ifTrue:[ |
2002 aProcess terminate |
2002 aProcess terminate |
2003 ] |
2003 ] |
2004 ] |
2004 ] |
2005 ]. |
2005 ]. |
2006 self terminate |
2006 self terminate |
2007 ! |
2007 ! |
2008 |
2008 |
2009 terminateNoSignal |
2009 terminateNoSignal |
2035 "Modified: 12.2.1997 / 12:41:38 / cg" |
2035 "Modified: 12.2.1997 / 12:41:38 / cg" |
2036 ! |
2036 ! |
2037 |
2037 |
2038 terminateSubprocesses |
2038 terminateSubprocesses |
2039 "terminate all the receivers subprocesses |
2039 "terminate all the receivers subprocesses |
2040 (i.e. all processes in the receivers process group, except for |
2040 (i.e. all processes in the receiver's process group, except for |
2041 the receiver itself)." |
2041 the receiver itself)." |
2042 |
2042 |
2043 id isNil ifTrue:[ |
2043 id isNil ifTrue:[ |
2044 "/ problem: |
2044 "/ problem: |
2045 "/ if receiver is already dead, its id is nil. |
2045 "/ if receiver is already dead, its id is nil. |
2046 "/ children are found by looking for processes with a parentID identical to |
2046 "/ children are found by looking for processes with a parentID identical to |
2047 "/ mine - ifNil, system processes are found, which is probably not what you |
2047 "/ mine - ifNil, system processes are found, which is probably not what you |
2048 "/ want ... |
2048 "/ want ... |
2049 "/ FIX: remember the id (or dont nil it when terminating) |
2049 "/ FIX: remember the id (or dont nil it when terminating) |
2050 "/ requires VM changes. |
2050 "/ requires VM changes. |
2051 ProcessorScheduler invalidProcessSignal |
2051 ProcessorScheduler invalidProcessSignal |
2052 raiseRequestWith:self |
2052 raiseRequestWith:self |
2053 errorString:'process is already dead - cannot determine child processes'. |
2053 errorString:'process is already dead - cannot determine child processes'. |
2054 ^ self |
2054 ^ self |
2055 ]. |
2055 ]. |
2056 processGroupId == 0 ifTrue:[ |
2056 processGroupId == 0 ifTrue:[ |
2057 ProcessorScheduler invalidProcessSignal |
2057 ProcessorScheduler invalidProcessSignal |
2058 raiseWith:self errorString:'trying to terminate the system process group'. |
2058 raiseWith:self errorString:'trying to terminate the system process group'. |
2059 ]. |
2059 ]. |
2060 ProcessorScheduler knownProcesses do:[:aProcess | |
2060 ProcessorScheduler knownProcesses do:[:aProcess | |
2061 aProcess ~~ self ifTrue:[ |
2061 aProcess ~~ self ifTrue:[ |
2062 (aProcess processGroupId == processGroupId |
2062 (aProcess processGroupId == processGroupId |
2063 or:[aProcess processGroupId == id]) ifTrue:[ |
2063 or:[aProcess processGroupId == id]) ifTrue:[ |
2064 aProcess terminate |
2064 aProcess terminate |
2065 ] |
2065 ] |
2066 ] |
2066 ] |
2067 ]. |
2067 ]. |
2068 |
2068 |
2069 "Created: 28.10.1996 / 20:41:49 / cg" |
2069 "Created: 28.10.1996 / 20:41:49 / cg" |
2070 "Modified: 26.8.1997 / 03:09:57 / cg" |
2070 "Modified: 26.8.1997 / 03:09:57 / cg" |
2071 ! |
2071 ! |