linux - How to run GUI application from userdefined boot time daemon server -
I'm writing daemon is a simple server up and running with /etc/init.d/server running properly But when I want to run a simple QT GUI with the system () function, it is not able to run it and returns 256 as the return code.
If the same work properly daemon running was terminal and system () function is also getting to be elevated success with return value 0 and GUI.
What is the problem that is not found ... plzzzz anyone can help me ..........
im down Ubuntu-9 .10 Usage code is ....
#include & lt; Stdio.h & gt; # Include & lt; Sys / types.h & gt; # Include & lt; Sys / socket.h & gt; # Include & lt; Arpa / inet.h & gt; #include & lt; Netinet / in.h> # Include & lt; Unistd.h & gt; # Include & lt; Stdlib.h & gt; #include & lt; String.h & gt; # Include & lt; Errno.h & gt; # Include & lt; Syslog.h & gt; Int main () {// local variable int sockfd, clifd, ret; Int client_flag = 0; Int server_flag = 1; Struct sockaddr_in server_addr, client_addr; Socklen_t client_len; Int server_len; Damon (0, 0); / * Open log file * / setmask (LOG_UPTO (LOG_INFO)); OpenLog ("server:", LOG_CONS | LOG_PID, LOG_LOCAL2); // Socket sockfd = Creating socket (AF_INET, SOCK_STREAM, 0); If (sokfad <0) {fall ("error socket creation:"); Return sockfd; } // Filling the socket address details Server_addr.sin_family = AF_INET; Server_addr.sin_port = htons (8181); Server_addr.sin_addr.s_addr = inet_addr ("127.0.0.1"); Server_len = sizeof (server_addr); // binding socket rate = tie (sockfd, (struct sockaddr *) & server_addr, server_len); If (rate at lieutenant; 0) {false ("error in bind"); Return writ; } // maintain the hearing queue = listen (sockfd, 10); If (rate at lieutenant; 0) {false ("error in hearing"); Return writ; } While accepting the connection from (1) {// client client_len = sizeof (client_addr); Clifd = Accept (sockfd, (struct sockaddr *) and client_addr, and client_len); If (Clyfd & Lt; 0) {Explanation ("Error in accepting in server_init"); Return clifed; } Client_flag = 0; // client_flag ret = read (clifd, & client_flag, sizeof (client_flag)); If (rate at lieutenant; 0) {false ("error in reading"); Return writ; } // If the flag is true, then I want to run GUI "console" / console Qt if 4 application (client_flag) {syslog (LOG_NOTICE, "************** \ N "); / * Here its return is 256 if it is running from boot time and if after reconstructing the "/etc/init.d/server restart" from the terminal I will get 0 success and the GUI pops up correctly Will happen. * / Rate = system ("/ usr / sbin / test / console 1"); Syslog (LOG_NOTICE, "*******************************************); } // server_flag write = write (write clifd, and server_flag, sizeof (server_flag); if (rate at lieutenant; 0) {false ("error in writing"); return writ;} close (cliff);} clauses (clause) ); close (sockfd); return 0;}
do not boot graphic applications go. they will not have access to the X server. a headless Damon Run, and write a GUI app to interact with it, which starts at a GUI login.
Comments
Post a Comment