summaryrefslogtreecommitdiff
path: root/src/ipc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipc.c')
-rw-r--r--src/ipc.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/ipc.c b/src/ipc.c
index b0e996fb..ce98b6cf 100644
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -176,8 +176,9 @@ iBool write_Ipc(iProcessId pid, const iString *input, enum iIpcWrite type) {
176 iFile *f = newCStr_File(inputFilePath_(&ipc_, pid)); 176 iFile *f = newCStr_File(inputFilePath_(&ipc_, pid));
177 if (open_File(f, text_FileMode | append_FileMode)) { 177 if (open_File(f, text_FileMode | append_FileMode)) {
178 write_File(f, utf8_String(input)); 178 write_File(f, utf8_String(input));
179 if (type == command_IpcWrite) { 179 if (type != response_IpcWrite) {
180 printf_Stream(stream_File(f), "\nipc.signal arg:%d\n", currentId_Process()); 180 printf_Stream(stream_File(f), "\nipc.signal arg:%d%s\n", currentId_Process(),
181 type == commandAndRaise_IpcWrite ? " raise:1" : "");
181 } 182 }
182 close_File(f); 183 close_File(f);
183 ok = iTrue; 184 ok = iTrue;
@@ -186,10 +187,10 @@ iBool write_Ipc(iProcessId pid, const iString *input, enum iIpcWrite type) {
186 return ok; 187 return ok;
187} 188}
188 189
189iString *communicate_Ipc(const iString *command) { 190iString *communicate_Ipc(const iString *command, iBool requestRaise) {
190 const iProcessId dst = check_Ipc(); 191 const iProcessId dst = check_Ipc();
191 if (dst) { 192 if (dst) {
192 if (write_Ipc(dst, command, command_IpcWrite)) { 193 if (write_Ipc(dst, command, requestRaise ? commandAndRaise_IpcWrite : command_IpcWrite)) {
193 response_ = new_IpcResponse(); 194 response_ = new_IpcResponse();
194 signal(SIGUSR1, handleSignal_IpcResponse_); 195 signal(SIGUSR1, handleSignal_IpcResponse_);
195 lock_Mutex(&response_->mtx); 196 lock_Mutex(&response_->mtx);
@@ -300,7 +301,7 @@ iBool write_Ipc(iProcessId pid, const iString *input, enum iIpcWrite type) {
300 return ok; 301 return ok;
301} 302}
302 303
303iString *communicate_Ipc(const iString *command) { 304iString *communicate_Ipc(const iString *command, iBool requestRaise) {
304 iProcessId pid = check_Ipc(); 305 iProcessId pid = check_Ipc();
305 if (!pid) { 306 if (!pid) {
306 return NULL; 307 return NULL;
@@ -308,7 +309,7 @@ iString *communicate_Ipc(const iString *command) {
308 /* Open a mailslot for the response. */ 309 /* Open a mailslot for the response. */
309 HANDLE responseSlot = CreateMailslotA(slotName_(currentId_Process()), 0, 1000, NULL); 310 HANDLE responseSlot = CreateMailslotA(slotName_(currentId_Process()), 0, 1000, NULL);
310 /* Write the commands. */ 311 /* Write the commands. */
311 if (!write_Ipc(pid, command, command_IpcWrite)) { 312 if (!write_Ipc(pid, command, requestRaise ? commandAndRaise_IpcWrite : command_IpcWrite)) {
312 CloseHandle(responseSlot); 313 CloseHandle(responseSlot);
313 return NULL; 314 return NULL;
314 } 315 }