26 #ifdef HAVE_SYS_TYPES_H
27 #include <sys/types.h>
30 #include <sys/socket.h>
33 #include <sys/select.h>
35 #include <sys/types.h>
36 #include <sys/param.h>
50 #define QT_CLEAN_NAMESPACE 1
53 #include <dcopclient.h>
55 #define BUFFER_SIZE 4096
57 extern TQCString dcopServerFile(
const TQCString &hostname,
bool old);
59 static char *getDisplay()
73 display = getenv(
"DISPLAY");
75 display = getenv(
"QWS_DISPLAY");
77 if (!display || !*display)
79 display =
"NODISPLAY";
81 result = (
char*)malloc(strlen(display)+1);
84 strcpy(result, display);
85 screen = strrchr(result,
'.');
86 colon = strrchr(result,
':');
87 if (screen && (screen > colon))
92 static void cleanupDCOPsocket(
const char *socketfile)
94 char cmd[BUFFER_SIZE];
95 char buffer[BUFFER_SIZE];
96 const char *socket_file;
99 l = strlen(socketfile);
102 strncpy(buffer,socketfile,l);
105 socket_file = strchr(buffer,
':');
112 snprintf(cmd, BUFFER_SIZE,
"iceauth remove netid='%s'", buffer);
117 static void killDCOPWin(pid_t pid)
120 sprintf(sz,
"dcopserver%i",pid);
121 HANDLE hEvent = CreateEventA(NULL,TRUE,FALSE,(LPCSTR)sz);
122 DWORD dwError = GetLastError();
123 printf(
"Signal event %s %p, %i\n",sz,hEvent,dwError);
132 static void cleanupDCOP(
int dont_kill_dcop,
int wait_for_exit)
137 if(strDCOPServer.isEmpty())
139 printf(
"no server file\n");
142 printf(
"server file %s\n",(
const char *)strDCOPServer);
145 TQFile f(strDCOPServer);
146 if(f.open(IO_ReadOnly))
149 while(f.readLine(str,2048))
154 cleanupDCOPsocket(str.ascii());
159 TQFile::remove(strDCOPServer);
160 printf(
"remove server file %s\n",(
const char *)strDCOPServer);
183 HANDLE hProcess = OpenProcess(SYNCHRONIZE,FALSE,(DWORD)pid);
186 WaitForSingleObject(hProcess,INFINITE);
187 CloseHandle(hProcess);
191 while(wait_for_exit && (kill(pid, 0) == 0))
201 int main(
int argc,
char **argv)
205 int dont_kill_dcop = (argc == 2) && (strcmp(argv[1],
"--nokill") == 0);
206 int wait_for_exit = (argc == 2) && (strcmp(argv[1],
"--wait") == 0);
208 cleanupDCOP(dont_kill_dcop, wait_for_exit);
static TQCString dcopServerFile(const TQCString &hostname=0)
File with information how to reach the dcopserver.