Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    program running on tty needs access to xwindow (no graphical user logged in)

    The title sort of says it all, but let me explain my situation a bit more. Let me warn you that although I have done some semi-complex things with linux I'm still a newbie who doesnít understand anything except those few explicit things I've had to figure out (and sometimes I don't really understand them )

    I have an application being installed by an RPM which must run in the background at all times, and must come up at bootup even if no one has logged in. I ended up deciding to create a user and automatically log that user on tty7 (which moved graphical mode to tty. The user has a line in his bash_profile that has him run our app and has very limited permissions other then sudo rights to run the app. I remember that there was a reason that I opted for having a user logged in rather then just putting my application in rc.5 to be run at bootup, something to do with other programs not being configured correctly when I attempted it that way, but I honestly can't recall what the reason was any more.

    Anyways this method has been working for some time, but I'm running into some trouble with xhost. When the computer boots up it logs on the user I created to tty7 as it should and the user attempts to run the APP; at which point I get the error "GTX-WARNING: cannot open display." Our application is not graphical, but it does use Java timers which I believe have to plug into the XHost.

    I originally had this problem on my personal laptop which I ultimately fixed by putting "xhost +" in the bashrc file, but I updated our RPM yesterday and now I get the same issue installing the RPM on a fresh install of RHEL 5.2. I'm not so eager to have our RPM implement the "xhost +" solution for obvious reasons.

    Anyways here what I know playing on the tty7 (the automatically logged on user).
    1) The DISPLAY variable is not set by default. I tried setting it to :0.0 but not surprisingly it doesnít work
    2) running xhost complains either that it cannot open display "", or that "xlib: connection to display :0.0 refused" if I try setting DISPLAY first
    3) startx fails because I cannot access display :0.0 (even though DISPLAY isn't set)
    4) If I switch to tty8 (graphical mode) and log in then switch back to tty7 and run my application it runs perfectly. Only problem is the app usually will have to run when no one is logged in.

    So what is happening? I understand that text modes are not supposed to be able to access xhost, but my rpm was working with this solution for some time before it broke. There must be some way to fix this without using the "xhost +local" solution that I see when I try to Google the problem, otherwise it wouldn't have worked before.

    As a side note my RPM is copying over the users home directory. I mention this incase there is some hidden boot file like .bash_profile or .bashrc that I might be copying over that causes trouble. I don't think that the case sense I've compared the files and they look identical to what they should, but I really don't know whatís happening so I'll give you all the information I can think of.

    help, advice, or links to someplace that can provide the same are appreciated. Thank you

  2. #2
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    NH, USA
    I assume this means you are using javax.swing.Timer class? If your app isn't graphical, do you need to use the graphics library timer or could you use one of the other 2?

    Try adding this on command line for your app.

  3. #3
    I assume this means you are using javax.swing.Timer class? If your app isn't graphical, do you need to use the graphics library timer or could you use one of the other 2?
    To be honest I'm not sure if swing timers are being used or a different timer, itís been awhile sense I touched the code. The timers were a guess as to the reason behind it needing to access xserver. I'll check what type of timer it's using as well as try the line you gave for running java.

    Still I think I'm going to have the same problem. I didn't mention it yet, but the program that is refusing to run is just a parent program that is suppose to spawn a bunch of child processes and monitor/control them. The child processes are graphical, and are being served out through VNC. So even if I got the parent program to run I would probably just run into the problem with the child processes.

    Incidentally I tried the hack of setting "xhost +" in bashrc just to see what would happen. That doesnít work actually, all it does is give me permission to access display :0.0 I still can't access that display unless I log into the graphical mode...

    What starts xserver anyways? When I run ps Ėef in graphical mode the only thing I find that looks at all associated with xserver are xfs (which Iím pretty sure isnít the issue) and a complicated line involving starting ssh which starts dbus-launch which starts xclients. I have only the vaguest idea what the second line is doingÖ

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts