changeset 23881:f4fc1826e04a

8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes Reviewed-by: dcubed, jbachorik
author sla
date Wed, 02 Apr 2014 12:03:25 +0200
parents 7d6b060131d3
children 7dbf42ed83ef
files jdk/test/com/sun/jdi/ShellScaffold.sh
diffstat 1 files changed, 21 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/test/com/sun/jdi/ShellScaffold.sh	Sat Apr 12 14:38:50 2014 -0700
+++ b/jdk/test/com/sun/jdi/ShellScaffold.sh	Wed Apr 02 12:03:25 2014 +0200
@@ -199,30 +199,26 @@
         return 1
     fi
 
-    if [ -z "$isWin98" ] ; then
-        if [ "$osname" = SunOS ] ; then
-            # Solaris and OpenSolaris use pgrep and not ps in psCmd
-            findPidCmd="$psCmd"
-        elif [ "$osname" = AIX ] ; then
-            findPidCmd="$psCmd"
-        else
+    case "$osname" in
+        SunOS | AIX)
+            $psCmd | $grep '^ *'"$1 " > $devnull 2>&1
+            res=$?
+            ;;
+        Windows* | CYGWIN*)
+            # Don't use ps on cygwin since it sometimes misses
+            # some processes (!).
+            tasklist /NH | $grep " $1 " > $devnull 2>&1
+            res=$?
+            ;;
+       *)
             #   Never use plain 'ps', which requires a "controlling terminal"
             #     and will fail  with a "ps: no controlling terminal" error.
             #     Running under 'rsh' will cause this ps error.
-            # cygwin ps puts an I in column 1 for some reason.
-            findPidCmd="$psCmd -e"
-        fi
-        $findPidCmd | $grep '^I* *'"$1 " > $devnull 2>&1
-        return $?
-    fi
-
-    # mks 6.2a on win98 has $! getting a negative
-    # number and in ps, it shows up as 0x...
-    # Thus, we can't search in ps output for 
-    # PIDs gotten via $!
-    # We don't know if it is running or not - assume it is.
-    # We don't really care about win98 anymore.
-    return 0
+            $psCmd -e | $grep '^ *'"$1 " > $devnull 2>&1
+            res=$?
+            ;;
+    esac
+    return $res
 }
 
 setup()
@@ -252,16 +248,10 @@
 
     ulimitCmd=
     osname=`uname -s`
-    isWin98=
     isCygwin=
     case "$osname" in
         Windows* | CYGWIN*)
             devnull=NUL
-            if [ "$osname" = Windows_98 -o "$osname" = Windows_ME ]; then
-                isWin98=1
-                debuggeeKeyword='we_cant_kill_debuggees_on_win98'
-                jdbKeyword='jdb\.exe'
-            fi
             case "$osname" in
                 CYGWIN*)
                     isCygwin=1
@@ -772,7 +762,7 @@
         sleep ${sleep_seconds}
         findPid $topPid
         if [ $? != 0 ] ; then
-            # Top process is dead.  We better die too
+            echo "--Top process ($topPid) is dead.  We better die too" >&2
             dojstack
             exit 1
         fi
@@ -977,19 +967,12 @@
             break
         fi
 
-        if [ ! -z "$isWin98" ] ; then
-            $psCmd | $grep -i 'JDB\.EXE' >$devnull 2>&1
-            if [ $? != 0 ] ; then
-                break
-            fi
-        fi
-
         # (Don't use jdbFailIfPresent here since it is not safe 
         # to call from different processes)
-	$grep -s 'Input stream closed' $jdbOutFile > $devnull 2>&1
-	if [ $? = 0 ] ; then
+        $grep -s 'Input stream closed' $jdbOutFile > $devnull 2>&1
+        if [ $? = 0 ] ; then
             dofail "jdb input stream closed prematurely"
-	fi
+        fi
 
         # If a failure has occured, quit
         if [ -r "$failFile" ] ; then