Revision: 1063
http://svn.sourceforge.net/r-gregmisc/?rev=1063&view=rev
Author: warnes
Date: 2007-03-06 14:10:24 -0800 (Tue, 06 Mar 2007)
Log Message:
-----------
Modify script to check for the presence of zombie processes
Added Paths:
-----------
trunk/fork/tests/test_many_fork_broken.R
Added: trunk/fork/tests/test_many_fork_broken.R
===================================================================
--- trunk/fork/tests/test_many_fork_broken.R (rev 0)
+++ trunk/fork/tests/test_many_fork_broken.R 2007-03-06 22:10:24 UTC (rev 1063)
@@ -0,0 +1,36 @@
+## This script starts child processes, but doesn't do anything about
+## collecting or ignoring child process return status. Consequently, it should
+## generate zombie child processes.
+
+library(fork)
+
+cat("Generating 100 child processes (to become zombies)...\n")
+for(i in 1:100)
+ {
+ pid = fork(slave=NULL)
+ if(pid==0)
+ {
+ #cat("Hi from child process",getpid(),".\n");
+ #Sys.sleep(10);
+ #cat("Bye from child process",getpid(),".\n");
+ exit()
+ }
+ }
+
+cat("Give them 10 seconds to die and exit..\n")
+Sys.sleep(10)
+
+cat("Check the process table to see if there are any zombies...\n")
+if(TRUE) # BSD-style PS command (Linux, Mac OSX, NetBSD)
+{
+ statusList = system("ps -o stat", intern=TRUE)[-1]
+} else
+{
+ statusList = system("ps -o s", intern=TRUE)[-1]
+}
+
+zombies = grep("[Zz]", statusList, value=TRUE)
+if(length(zombies)>50)
+ stop(length(zombies), " Zombie Processes Present!")
+else
+ cat("Done. No Zombies present.\n")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|