--- a/reports/Builder__ReportRunner.st Thu Jun 27 14:44:49 2013 +0200
+++ b/reports/Builder__ReportRunner.st Fri Jun 28 02:14:45 2013 +0200
@@ -26,8 +26,10 @@
super initialize.
debugging := Transcript notNil and:[Transcript isView].
+ self setupSignalHandlers.
"Created: / 06-11-2011 / 22:07:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 28-06-2013 / 01:13:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ReportRunner class methodsFor:'command line options'!
@@ -92,6 +94,57 @@
"Created: / 15-05-2013 / 16:50:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!ReportRunner class methodsFor:'debugging'!
+
+dumpProcess: aProcess
+ Stderr cr; cr
+
+ "Created: / 27-06-2013 / 23:41:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+dumpProcess: aProcess on: aStream
+ | ctx |
+ aStream cr; cr.
+ aStream nextPutAll: '== ['; nextPutAll: aProcess id printString; nextPutAll:'] '; nextPutAll: aProcess name; nextPutAll: ' =='; cr.
+ aStream cr.
+
+ ctx := aProcess == Processor activeProcess ifTrue:[thisContext] ifFalse:[aProcess suspendedContext].
+ [ ctx notNil ] whileTrue:[
+ aStream nextPutAll: ' '.
+ ctx fullPrintOn: aStream.
+ aStream cr.
+ ctx := ctx sender.
+ ].
+ aStream cr.
+
+ "
+ self dumpProcess: Processor activeProcess on: Transcript.
+ "
+
+ "Created: / 28-06-2013 / 01:00:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+dumpProcesses
+ self dumpProcessesOn: Stderr
+
+ "
+ self dumpProcessesOn: Transcript.
+ "
+
+ "Created: / 27-06-2013 / 23:41:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified (comment): / 28-06-2013 / 01:06:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+dumpProcessesOn: aStream
+ Process allInstancesDo:[:process|
+ process isDead ifFalse:[
+ self dumpProcess: process on: aStream
+ ]
+ ]
+
+ "Created: / 27-06-2013 / 23:42:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!ReportRunner class methodsFor:'defaults'!
allowCoverageMeasurementOption
@@ -136,6 +189,48 @@
!ReportRunner class methodsFor:'startup'!
+handleSIGTERM
+ self dumpProcesses.
+ debugging ifFalse:[
+ Smalltalk exit:127.
+ ].
+
+ "Created: / 27-06-2013 / 23:10:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 28-06-2013 / 01:08:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+handleSIGUSR2
+ self dumpProcesses
+
+ "Created: / 27-06-2013 / 23:10:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+setupSignalHandlers
+ "On UNIX, this sets up a custom signal handler on SIGUSR2 and SIGTERM that
+ dumps stacks on all threads"
+
+ OperatingSystem isUNIXlike ifTrue:[
+ | sigusr2 sigterm |
+
+ sigterm := Signal new.
+ sigterm handlerBlock: [:ex | self handleSIGTERM].
+ OperatingSystem operatingSystemSignal:OperatingSystem sigTERM install: sigterm.
+ OperatingSystem enableSignal: OperatingSystem sigTERM.
+
+ sigusr2 := Signal new.
+ sigusr2 handlerBlock: [:ex | self handleSIGUSR2].
+ OperatingSystem operatingSystemSignal:OperatingSystem sigUSR2 install: sigusr2.
+ OperatingSystem enableSignal: OperatingSystem sigUSR2.
+ ].
+
+ "
+ OperatingSystem sendSignal: OperatingSystem sigUSR2 to: OperatingSystem getProcessId
+ "
+
+ "Created: / 27-06-2013 / 20:57:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 28-06-2013 / 01:11:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
setupToolsForDebug
super setupToolsForDebug.