changeset 1712:9fcca0aae3da

6787605: OpenSolaris doesn't have /usr/ucb/ps so ShellScaffold fails Reviewed-by: dcubed
author tbell
date Fri, 02 Oct 2009 08:49:25 -0700
parents e782a9564eae
children 97f17e6d0560
files test/com/sun/jdi/ShellScaffold.sh
diffstat 1 files changed, 22 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/test/com/sun/jdi/ShellScaffold.sh	Fri Oct 02 13:59:37 2009 +0100
+++ b/test/com/sun/jdi/ShellScaffold.sh	Fri Oct 02 08:49:25 2009 -0700
@@ -193,11 +193,17 @@
 {
     # Return 0 if $1 is the pid of a running process.
     if [ -z "$isWin98" ] ; then
-        #   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.
-        $psCmd -e | $grep '^I* *'"$1 " > $devnull 2>&1
+        if [ "$osname" = SunOS ] ; then
+            #Solaris and OpenSolaris use pgrep and not ps in psCmd
+            findPidCmd="$psCmd"
+        else
+            #   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
 
@@ -292,7 +298,17 @@
          # On linux, core files take a long time, and can leave
          # zombie processes
          if [ "$osname" = SunOS ] ; then
-             psCmd="/usr/ucb/ps -axwww"
+             #Experiments show Solaris '/usr/ucb/ps -axwww' and
+             #'/usr/bin/pgrep -f -l' provide the same small amount of the
+             #argv string (PRARGSZ=80 in /usr/include/sys/procfs.h)
+             # 1) This seems to have been working OK in ShellScaffold.
+             # 2) OpenSolaris does not provide /usr/ucb/ps, so use pgrep
+             #    instead
+             #The alternative would be to use /usr/bin/pargs [pid] to get
+             #all the args for a process, splice them back into one
+             #long string, then grep.
+             UU=`/usr/bin/id -un`
+             psCmd="pgrep -f -l -U $UU"
          else
              ulimit -c 0
              # See bug 6238593.