Hi,

here is the current version (please find the script below). works on linux.
If you can check on mac or guide me to a solution...
ps -o pid= --ppid 1
ps -o pgid= --pid 1

Thank you.

PS: HBase, the big data solution for High Range Linux Servers or MacBook
only :-)

#get the list of the process considered as dead
# i.e.: in the same group as the script and with a ppid of 1
# We do this because surfire can leave some dead process, so
# we will jstack them and kill them
function createListDeadProcess {
  id=$$
  listDeadProcess=""

  #list of the process with a ppid of 1
  sonProcess=`ps -o pid= --ppid 1`

  #then the process with a pgid of the script
  for pId in $sonProcess
  do
    pgid=`ps -o pgid= --pid $pId | sed 's/ //g'`
    if [ "$pgid" == "$id" ]
    then
      listDeadProcess="$pId $listDeadProcess"
    fi
  done
}

On Sat, Nov 5, 2011 at 4:12 PM, Ted Yu <[email protected]> wrote:

> Hi,
> Working on HBASE-4737, we found that the standard way of getting pid / ppid
> doesn't work on MacOS.
>
> According to N:
>
> from
>
> http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/ps.1.html
>
> could you check if
> ps -o pid --no-headers -$id
> works (with $id equals to 1 for example: is should return 1 as it's the pid
> of the 'init' process, see the '-' before $id)
>
> same for
> ps -o ppid --pid $pId --no-headers
> With for example 1 for  $pId. Should return 0
>
> last is:
> ps -o comm
> should show 'java' for java process
>
> ------
> Here is what I got:
>
> zhihyu$ ps -o pid --no-headers -1
> ps: illegal option -- -
> usage: ps [-AaCcEefhjlMmrSTvwXx] [-O fmt | -o fmt] [-G gid[,gid...]]
>          [-g grp[,grp...]] [-u [uid,uid...]]
>          [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]
>       ps [-L]
> ~ zhihyu$ ps -o comm
> COMM
> -sh
> -sh
> -sh
> /Users/zhihyu/eclipse/Eclipse.app/Contents/MacOS/eclipse
>
> ------
> If you have experience with using ps command on Mac, please comment.
>
> Thanks
>

Reply via email to