On Mon, Jan 12, 2009 at 10:10:46PM +0100, intrigeri wrote:
> Tuomas Jormola wrote (12 Jan 2009 15:01:03 GMT) :
> > On Mon, Jan 12, 2009 at 01:17:59PM +0100, intrigeri wrote:
> >> As pointed out in your comments, the checkpidalive portability needs
> >> to be fixed; do you intend to do so at some point?
> > Quick check on Linux/AIX/Solaris/Mac OS X systems would suggest that
> > ps -A | awk '{print $1}' would give you the list of all the pids running
> > on the system. On HP-UX, it's ps -e. So maybe something like this could
> > be done (untested, and we should check at least how *BSD ps behaves)
> 
> > function checkpidalive() {
> >     local pid="$1"
> >     [ -z "$pid" ] && return 2
> >     [ -d /proc/$pid ] && return 0
> >     local psargs
> >     local uname=`uname`
> >     case "$uname" in
> >             HP-UX) psargs="-e" ;;
> >             *)     psargs="-A" ;;
> >     esac
> >     ps $psargs | awk '{print $1}' | grep -q "^${pid}$"
> >     return $?
> > }
> 
> Seems fine to me at the first glance, but... have you checked how
> other programs do so? I bet there is a robust, long-time used piece of
> code somewhere that does exactly this and takes care of the usual
> weird corner case.
In shell, I guess you're pretty much limited to use what ever commands
you have at your disposal. ps is the utility to get information about
running processes, so I don't see there's lots of other options...

-- 
Tuomas Jormola <t...@solitudo.net>

Attachment: signature.asc
Description: Digital signature

Reply via email to