On Sat, 16 Dec 2006 14:12:13 +0100, "Jesus Climent"
<[EMAIL PROTECTED]> said:
> The only problem with the script that thttpd ships right now is a missing
> space between "^" and "$PID":
> 
>             if ps ax | grep -q "^ $PID"; then
> 
> since "ps ax" puts a space in the begining.

Actually, seems it pads the PID to five digits, so you may or may not
get one or more spaces, depending on the width of the PID.

Is this version dependent? That would explain why people are trying
different things and not getting it right. But IIRC it has been this way
in my version of ps for quite some time.

Also, if you happen to get PID 123, then the grep will match 1234, 12345
as well, so you should bound it on both sides.

Personally, on a Debian-based system, I would perhaps try to use a more
specific option to ps(1) to look for the PID in question. "ps --pid
$PID" would appear to do that, and seems to return useful error status.
You'll also need to redirect to /dev/null if you don't want artefacts to
be displayed on the screen (grep -q handled that in the original code).

Hope this helps,

/* era */

-- 
If this were a real .signature, it would suck less.  Well, maybe not.



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to