[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: test if x server is running on a given display



Dave Howorth wrote:

know whether there's a way to contact the server directly to see whether it's
REALLY running....


The simplest way to me is to write an X client program that just makes a connection, then disconnects. Something like this in fact:

#include <X11/Xlib.h>
#define DISPLAY ":0.0"

int main(argc, argv) int argc; char **argv; {
 exit(XOpenDisplay(DISPLAY) ? 0 : -1);
}

Then cc -L/usr/X11R6/lib -lX11 xtest.c

Cheers, Dave


thanks dave, that's very cool. now... I don't program in c. would it be easy to modify this program in two ways:
1) pass the display number as a parameter
2) print or return a specific error message if the connection is not accepted?

Matt



Reply to: