Process.st
changeset 202 40ca7cc6fb9c
parent 182 f531860566fc
child 213 3b56a17534fd
--- a/Process.st	Thu Nov 17 15:12:25 1994 +0100
+++ b/Process.st	Thu Nov 17 15:18:16 1994 +0100
@@ -24,7 +24,7 @@
 COPYRIGHT (c) 1992 by Claus Gittinger
 	     All Rights Reserved
 
-$Header: /cvs/stx/stx/libbasic/Process.st,v 1.16 1994-10-28 01:28:37 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Process.st,v 1.17 1994-11-17 14:17:56 claus Exp $
 '!
 
 !Process class methodsFor:'documentation'!
@@ -45,7 +45,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libbasic/Process.st,v 1.16 1994-10-28 01:28:37 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Process.st,v 1.17 1994-11-17 14:17:56 claus Exp $
 "
 !
 
@@ -59,14 +59,37 @@
     Also notice, that heavy-weight process creation takes much longer.
     (see OperatingSystemclass>>fork).
 
-    Processes are typically created by sending #fork or #forkAt: to a block.
+    Processes are typically created by sending #fork or #forkAt: to a block;
+    the block creates a new process, defines itself as its startBlock,
+    and (optionally) tells the Processor about the new process.
+
     Scheduling is done by Processor, which is the sole instance of 
     ProcessorScheduler.
 
-    Notice: in Smalltalk/X, processes are gone, when an image is restarted;
-    this means, that you have to take care of process re-creation yourself.
-    Usually, this is done by depending on ObjectMemory, recreating the
-    process(s) when the #returnFromSnapshot-change notifiaction arrives.
+    Processes can be terminated either soft or via a hardTerminate.
+    A soft terminate (see Process>>terminate) will raise a TerminationSignal
+    in the process, which can be handled. If no other handler was specified,
+    the processes own handler (see Process>>start) will catch the signal
+    and terminate the process. During this signal processing, normal unwind
+    processing takes place, this means that with a soft terminate, all 
+    valueOnUnwind:/valueNowOrOnUnwind: cleanup blocks are evaluated.
+    (so a process which has set up those blocks correctly does not have to
+     care especially about cleanup in case of termination).
+
+    A hard terminate (Process>>terminateNoSignal) will NOT do all of the above,
+    but quickly (and without any cleanup) terminate the process.
+    The debugger offers a quickTerminate option on its popupMenu for
+    situations, when soft termination fails. (for example, if some error was
+    coded into a handler or unwind block).
+
+    Notice: 
+	in Smalltalk/X, processes are gone, when an image is restarted;
+	this means, that you have to take care of process re-creation yourself.
+	Usually, this is done by depending on ObjectMemory, recreating the
+	process(s) when the #returnFromSnapshot-change notifiaction arrives.
+
+	All views (actually windowGroups) recreate their window process
+	on image-restart. You have to do so manually for your own processes.
 
     A later version will allow specification of automatic restart, but
     thats not yet implemented.
@@ -74,16 +97,24 @@
     Instance variables:
 
 	id                     <SmallInteger>   a unique process-id
+
 	prio                   <SmallInteger>   the processes priority
+
 	state                  <Symbol>         the processes state
 						(for process-monitor)
-	startBlock             <Block>          the startup-block
+
+	startBlock             <Block>          the startup-block (the one that forked)
+
 	name                   <String-or-nil>  the processes name (if any)
 						(for process-monitor)
+
 	restartable            <Boolean>        is restartable (not yet implemented)
+
 	interruptActions       <Collection>     interrupt actions as defined by interruptWith:,
 						performed at interrupt time
-	exitAction             <Block>          action to perform on termination
+
+	exitAction             <Block>          additional cleanup action to perform on termination
+                                                
 	emergencySignalHandler <Block>          can be used for per-process
 						emergency signal handling
     Class variables:
@@ -107,6 +138,8 @@
 !Process class methodsFor:'signal access'!
 
 terminateSignal
+    "return the signal used for process termination"
+
     ^ TerminateSignal
 ! !
 
@@ -385,7 +418,9 @@
 
     id := idNumber.
     state := stateSymbol.
-!
+! !
+
+!Process methodsFor:'startup '!
 
 start
     "start the process - this is sent by the VM to the process to get
@@ -404,9 +439,11 @@
 	    name := '(' , startBlock displayString , ')'
 	].
 	startBlock := nil.
-	TerminateSignal handle:[:ex |
+	(SignalSet with:TerminateSignal with:(Object abortSignal))
+	handle:[:ex |
 	    ex return
 	] do:block.
+
 	(block := exitAction) notNil ifTrue:[
 	    exitAction := nil.
 	    block value.