Checking if the X Server is running
Jörg Schaible
Joerg.Schaible@Elsag-Solutions.com
Tue Oct 2 15:14:00 GMT 2007
cygwin-xfree-owner@cygwin.com wrote on Tuesday, October 02, 2007 4:21 PM:
> 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.
pidof XWin
- Jörg
--
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/
More information about the Cygwin-xfree
mailing list