Linux.com

Author Message
Raj
Joined: Jun 26, 2008
Posts: 8
Other Topics
Posted Jul 28, 2008 at 6:14:14 AM
Subject: xmessage problems again
I had received some help in the forum for the issue when I posted it last time. But the suggestions could not clear the problems. The case is as follows I have written a program for scada application. I used a script to automatically start it at run-level 5. Now, the program gets executed at boot time. It forks into memory and stays active. It works fine and reports issues to syslog. But, xmessage command does not work!! I am trying it in Suse and program was written is C. It just invokes system(xmessage(mymsgstring)) but xmessages do not pop-up at all. But if I execute the same script in terminal or just by doubleclicking it, xmessage works fine and the messages pop-up properly. To this problem I was advised to set the display variables, and I tried the suggestions. First, I tried to change the DISPLAY environment in the script. I used the command env|grep DISPLAY >/dev/null || { DISPLAY=:0.0; export DISPLAY; } in the script that is executed by the start-up script and also in the startup script. #!/bin/sh was used for running. Script did not give any errors. But xmessage doesn't work!!! No pop ups came!! 1. I inserted the line " env|grep DISPLAY >/dev/null || { DISPLAY=:0.0; export DISPLAY; } " both in the startup script and the actual script that is run by the startup script. 2. I also tried removing the second script altogether and directly running the program in the start up script. 3. I again tried removing the line from the start-up script and using it only in the script run by the startup script. 4. I further tried running the scripts immediately after booting, ie: in boot.local file. But nothing works. Scripts are run at runlevel 5. The program works fine except for the xmessage. It reports issues to syslog also correctly. If I kill the program after startup and then execute it again manually, messages also pop up correctly. Then I tried modifying the c program. I found out that, even after inserting putenv("DISPLAY=:0.0") in my c program, xmessage doesn't work. Actually, program exits the parent and forks into a daemon that scans the port to which a scada controller is connected. putenv("DISPLAY=:0.0") was inserted at the entry point in the parent, and even in the entry point in the child. program compiles fine without any errors or warnings, but xmessage doesn't work!! Everything else works correctly. But, as I mentioned, if I kill the program after startup and then execute it again manually, messages pop up correctly. Any suggestions would be of great help.
Back to top Profile Email Website
Raj
Joined Jun 26, 2008
Posts: 8

Other Topics
Posted: Jul 30, 2008 8:58:13 PM
Subject: xmessage problems again
Forgive me if I am wrong, but I feel like concluding that, xmessage will never work if executed from a program that runs before a user logs in. Because, the xmessage doesn't know to whom it should be displayed to!! Probably this is a stupid thing to say !! 1. If I do wall in a c program, nothing comes on the screen (unless I am in a terminal, executing the program in terminal mode. Actually, before the program forks into a child, walled messages appear on the terminal. But afterwards, all walls don't appear on the screen, probably because the child program doesn't know to which session the wall messages should be displayed (??!!!). Am I right here? I was wondering again, that the same thing could be happening to xmessage. Since it doesn't know whom to show the message, or in which session to show the message, it doesn't come up!! But when the program is executed manually by doubleclicking it or in the terminal mode, it shows the messages to the current user!! This sounds like nonsense to me, but since it is not showing up, I can't but reach this conclusion!!! In the same C program, I tried to execute a script (in the child part, after forking) which has an xmessage "testing". But the message doesn't come up!! Kindly comment!!!! Is there a way I can at least show the message in a terminal window? like wall output?
Back to top Profile Email Website
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya