This is the mail archive of the cygwin-xfree mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Checking if the X Server is running


On Mon, Oct 01, 2007 at 05:33:12PM +0100, Phil Betts wrote:
> It's probably not the cause of your problem, but you should
> never use "ps | grep xxx" to detect if a process is running.
> This is because the grep process will (sometimes) detect 
> itself and give you a false positive, and your xterm will 
> try to start when there is no server running.

A just a random snippet that I find useful for preventing just that:
ps | grep xterm
matches itself, since the command line contains 'xterm'.

ps | grep '[x]term'
doesn't match itself, since the command line no longer contains the
string 'xterm'.

It's more portable than
pgrep xterm

and it's less ugly than
ps | grep xterm | grep -v grep

So it's what I usually find myself using.

~Matt

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]