geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r509107 - /geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/util/BastardChildReaper.groovy
Date Mon, 19 Feb 2007 06:14:54 GMT
Author: jdillon
Date: Sun Feb 18 22:14:53 2007
New Revision: 509107

URL: http://svn.apache.org/viewvc?view=rev&rev=509107
Log:
Protect methods

Modified:
    geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/util/BastardChildReaper.groovy

Modified: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/util/BastardChildReaper.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/util/BastardChildReaper.groovy?view=diff&rev=509107&r1=509106&r2=509107
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/util/BastardChildReaper.groovy
(original)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/util/BastardChildReaper.groovy
Sun Feb 18 22:14:53 2007
@@ -34,17 +34,6 @@
 {
     private AntBuilder ant = new gbuild.system.util.AntBuilder()
     
-    /**
-     * The process ID of the current process.
-     */
-    String pid
-    
-    BastardChildReaper() {
-        pid = sh('echo $PPID')
-        
-        log.info "PID: $pid"
-    }
-    
     private String sh(String script, List args) {
         assert script
         
@@ -73,7 +62,7 @@
         return sh(script, null)
     }
     
-    def ps(String pattern) {
+    private List ps(String pattern) {
         log.info "Getting process list, pattern: $pattern"
         
         def ps
@@ -117,11 +106,14 @@
         return result
     }
     
-    def ps() {
+    private List ps() {
         return ps(null)
     }
     
-    def children(procs, pid) {
+    /**
+     * Returns a list of children (and children's children) for the given pid
+     */
+    private List children(procs, pid) {
         assert procs
         assert pid
         
@@ -131,6 +123,7 @@
             if (it.PPID == pid) {
                 list << it
                 
+                // Include children's children if any
                 def l = children(procs, it.PID)
                 if (l) {
                     list.addAll(l)
@@ -141,9 +134,10 @@
         return list
     }
     
-    def kill(pid, boolean force) {
+    private void kill(pid, boolean force) {
         log.info "Killing $pid" + (force ? '; forcfully' : '')
         
+        // Don't fail on error, proc might have die in the time it took to call kill
         ant.exec(executable: 'kill', failonerror: false) {
             if (force) {
                 arg(value: '-9')
@@ -152,11 +146,11 @@
         }
     }
     
-    def kill(pid) {
-        return kill(pid, false)
+    private void kill(pid) {
+        kill(pid, false)
     }
     
-    def debugSpawn(String script) {
+    private void debugSpawn(String script) {
         assert script
         
         def file = File.createTempFile('reaper', '.sh')
@@ -170,7 +164,9 @@
     }
     
     def reap() {
-        log.info 'Reaping bastard children'
+        String pid = sh('echo $PPID')
+        
+        log.info "Reaping bastard children of $pid"
         
         /*
         def t1 = new Thread({ debugSpawn('(/bin/sleep 10 & (/bin/sleep 10 &)); sleep
10') })



Mime
View raw message