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>
52 #include <dcopclient.h>
54 #define BUFFER_SIZE 4096
56 extern TQCString dcopServerFile(
const TQCString &hostname,
bool old);
58 static char *getDisplay()
72 display = getenv(
"DISPLAY");
74 display = getenv(
"QWS_DISPLAY");
76 if (!display || !*display)
78 display =
"NODISPLAY";
80 result = (
char*)malloc(strlen(display)+1);
83 strcpy(result, display);
84 screen = strrchr(result,
'.');
85 colon = strrchr(result,
':');
86 if (screen && (screen > colon))
91 static void cleanupDCOPsocket(
const char *socketfile)
93 char cmd[BUFFER_SIZE];
94 char buffer[BUFFER_SIZE];
95 const char *socket_file;
98 l = strlen(socketfile);
101 strncpy(buffer,socketfile,l);
104 socket_file = strchr(buffer,
':');
111 snprintf(cmd, BUFFER_SIZE,
"iceauth remove netid='%s'", buffer);
116 static void killDCOPWin(pid_t pid)
119 sprintf(sz,
"dcopserver%i",pid);
120 HANDLE hEvent = CreateEventA(NULL,TRUE,FALSE,(LPCSTR)sz);
121 DWORD dwError = GetLastError();
122 printf(
"Signal event %s %p, %i\n",sz,hEvent,dwError);
131 static void cleanupDCOP(
int dont_kill_dcop,
int wait_for_exit)
136 if(strDCOPServer.isEmpty())
138 printf(
"no server file\n");
141 printf(
"server file %s\n",(
const char *)strDCOPServer);
144 TQFile f(strDCOPServer);
145 if(f.open(IO_ReadOnly))
148 while(f.readLine(str,2048))
153 cleanupDCOPsocket(str.ascii());
158 TQFile::remove(strDCOPServer);
159 printf(
"remove server file %s\n",(
const char *)strDCOPServer);
182 HANDLE hProcess = OpenProcess(SYNCHRONIZE,FALSE,(DWORD)pid);
185 WaitForSingleObject(hProcess,INFINITE);
186 CloseHandle(hProcess);
190 while(wait_for_exit && (kill(pid, 0) == 0))
200 int main(
int argc,
char **argv)
204 int dont_kill_dcop = (argc == 2) && (strcmp(argv[1],
"--nokill") == 0);
205 int wait_for_exit = (argc == 2) && (strcmp(argv[1],
"--wait") == 0);
207 cleanupDCOP(dont_kill_dcop, wait_for_exit);
static TQCString dcopServerFile(const TQCString &hostname=0)
File with information how to reach the dcopserver.