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

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





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?

-- NEW VERSION --
#include <X11/Xlib.h>

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

$ gcc -o xprobe xprobe.c -L/usr/X11R6/lib -lX11


Now:

xprobe from an xterm:   Connects to the xterm's server
xprobe from .xinitrc:   Connects to new server
xprobe from a VT:       Fails
DISPLAY=display xprobe  Connects to display 'display'

As for an error message, here's what I'd do:

xprobe || echo "Foo! server not responding?" >&2
wicked cool!  thanks
matt



Reply to: