You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2019/05/28 14:55:28 UTC

[karaf] branch karaf-4.2.x updated: [KARAF-6290] Enhance wrapper pid management on Solaris

This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch karaf-4.2.x
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/karaf-4.2.x by this push:
     new ef37f7a  [KARAF-6290] Enhance wrapper pid management on Solaris
     new 175a8f1  Merge pull request #855 from baptistedaroit/KARAF-6290
ef37f7a is described below

commit ef37f7a983c955cf60aa1930dede391ce9ccb6e9
Author: Baptiste DA ROIT <ba...@aspera.com>
AuthorDate: Tue May 28 16:05:16 2019 +0200

    [KARAF-6290] Enhance wrapper pid management on Solaris
---
 .../karaf/wrapper/internal/unix/karaf-service      | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-service b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-service
index 7defa82..0e66e00 100644
--- a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-service
+++ b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-service
@@ -367,12 +367,37 @@ getpid() {
                 if [ "$DIST_OS" = "solaris" ]
                 then
                     pidtest=`$PSEXE -p $pid -o comm | grep $WRAPPER_CMD | tail -1`
+                    # On Solaris, standard ps is truncated so even if pid is running, pidtest 
+                    # can be empty when path to wrapper exe is too long 
+                    if [ "X$pidtest" = "X" ]
+                    then 
+                        # Using pargs and /usr/ucb/ps thus allows to secure pid check  
+                        PARGSEXE="`command -v pargs 2>/dev/null`"
+                        if [ "X$PARGSEXE" != "X" ]
+                        then
+                            pidtest=`$PARGSEXE $pid | grep $WRAPPER_CMD | tail -1 | awk '{print $2}'`
+                        fi
+                        if [ "X$pidtest" = "X" ]
+                        then
+                            if [ -x "/usr/ucb/ps" ]
+                            then 
+                                pidtest=`/usr/ucb/ps -axwww $pid | grep $WRAPPER_CMD | tail -1 | awk '{print $5}'`  
+                            fi
+                        fi
+                    fi
                 elif [ "$DIST_OS" = "aix" ]
                 then
                     pidtest=`$PSEXE -p $pid -o args | grep "$WRAPPER_CMD" | tail -1`
                 elif [ "$DIST_OS" = "hpux" ]
                 then
                     pidtest=`UNIX95= $PSEXE -p $pid -o args | grep "$WRAPPER_CMD" | tail -1`
+                    # Such as on Solaris, standard ps is truncated on HP-UX so even if pid is running, pidtest
+                    # can still be empty when path to wrapper exe is too long
+                    if [ "X$pidtest" = "X" ]
+                    then
+                        # On latest HP-UX platforms, -x option has been added to allow printing full command args
+                        pidtest=`$PSEXE -p $pid -x 2>/dev/null | grep "$WRAPPER_CMD" | tail -1 | awk '{print $4}'`
+                    fi
                 else
                     pidtest=`$PSEXE -p $pid -o command | grep $WRAPPER_CMD | tail -1`
                 fi