Detecting a lost X connection
I am using linux computers and on one computer I am setting my DISPLAY to COMP1 and then starting a Java Gui program on COMP2. The problem is that when I disconnect the network cord or log out of COMP1 the Java program continues running fine on COMP2 without any indication that the display is no longer accessable. This is a problem because that Gui had a "master gui" status and since the process still thinks everything is fine it doesn't give up that "master gui" status so that it can be available for other guis.
Is there some way that I can detect if the connection (I think it might be the X connection) from the java process to the display is no longer available? If I can detect that then I can just have that process exit and free up the "master gui" status.