Alex Zbyslaw wrote:
Eric Schuele wrote:

Hello,

I am sure this is quite trivial, but...

I have need to determine if an app (firefox, or anything really) is already running before I perform some action. So I grep the ps output. However sometimes (many times) that which I'm searching for is present in the output because I am presently grep'ing for it. But it is not always there. It seems to be a bit inconsistent. (See below).

I was wondering if someone could explain why it is sometimes there and not other times. And how I should correctly go about detecting if the process is running before I perform my action.

ps | egrep firefox | egrep -v egrep


Thanks guys.  Yes... both solutions do fix the problem.

Hmm... guess I should've looked before I lept. I assumed the processes were run in order by the shell... however it appears all are started simultaneously as a group.

I can't explain exactly why. It's clearly a timing thing. I guess if the ps runs quickly enough then perhaps the grep hasn't actually been started by the shell.

Or if ps iterates over something, then maybe the grep appears in a part of the list that has already been looked at by ps.

--Alex


_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"



--
Regards,
Eric
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to