Re: How to determine whether X is useable?
From: Kenny McCormack (gazelle_at_yin.interaccess.com)
Date: 06/06/05
- Next message: Bill Marcum: "Re: How to determine whether X is useable?"
- Previous message: bryanwilkerson_at_yahoo.com: "Re: why can't I read stdout of child process"
- In reply to: Måns Rullgård: "Re: How to determine whether X is useable?"
- Next in thread: Barry Margolin: "Re: How to determine whether X is useable?"
- Reply: Barry Margolin: "Re: How to determine whether X is useable?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 06 Jun 2005 15:31:06 GMT
In article <yw1xoeajn973.fsf@ford.inprovide.com>,
=?iso-8859-1?q?M=E5ns_Rullg=E5rd?= <mru@inprovide.com> wrote:
>"zibingrong" <zibingrong@sina.com> writes:
>
>> Hi,
>> How can I determine whether X is useable in a certain environment?
>> I want to write a application that have different behavior in run
>> level 3(or login via a terminal) and run level 5, just like the emacs does,
>> how would I do? thanks!
>
>Try to open the display (XOpenDisplay). If it fails, there's no X.
There may be an issue of timing - that is, if you try to open the display,
it can take a while for it to fail and then your application startup is
slow. I think it is reasonable to check DISPLAY first (although you are
technically correct that DISPLAY is not *required* for X to be running, in
practice it always will be set). Then if DISPLAY is set, you can try to
"xping" it (see below) to verify that it is running.
Then there is the question of timing - how long to wait. Any number you
pick will be arbitrary. I have a tool in my toolkit called "xping", that
waits 3 seconds for the display to open successfully. That seems to be
fine in practice, but, as you can see, it was an arbitrary choice.
Finally, the OP mentions run levels. Erroneously, I believe (since the
system run level is a constant [at any given point in time] regardless of
how you log in), but it is possible that he means what he says and that he
really just wants to know which run level the system is in. If so, then it
should be possible to get that information (how is system-specific and left
as material for another thread) w/o bothering the question of "Is X running?"
at all.
- Next message: Bill Marcum: "Re: How to determine whether X is useable?"
- Previous message: bryanwilkerson_at_yahoo.com: "Re: why can't I read stdout of child process"
- In reply to: Måns Rullgård: "Re: How to determine whether X is useable?"
- Next in thread: Barry Margolin: "Re: How to determine whether X is useable?"
- Reply: Barry Margolin: "Re: How to determine whether X is useable?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|