3 * - manage I/O pipes (several ones, and stdin)
4 * - manage SetConsoleCtrlHandler ?
5 * - the child process seems to still run after the DEL event
18 #include "ecore_private.h"
20 #define WIN32_LEAN_AND_MEAN
22 #undef WIN32_LEAN_AND_MEAN
25 #define ECORE_EXE_WIN32_TIMEOUT 3000
29 ECORE_EXE_WIN32_SIGINT,
30 ECORE_EXE_WIN32_SIGQUIT,
31 ECORE_EXE_WIN32_SIGTERM,
32 ECORE_EXE_WIN32_SIGKILL
33 } Ecore_Exe_Win32_Signal;
41 HANDLE process; /* CloseHandle */
42 HANDLE process_thread;
48 Ecore_Exe_Flags flags;
49 Ecore_Exe_Win32_Signal sig;
50 Ecore_Win32_Handler *h_close;
65 Ecore_Win32_Handler *h;
78 Eina_Bool close_stdin : 1;
79 Eina_Bool is_suspended : 1;
81 Ecore_Exe_Cb pre_free_cb;
84 static Ecore_Exe *exes = NULL;
86 static int _ecore_exe_win32_pipes_set(Ecore_Exe *exe);
87 static void _ecore_exe_win32_pipes_close(Ecore_Exe *exe);
89 static BOOL CALLBACK _ecore_exe_enum_windows_procedure(HWND window,
91 static void _ecore_exe_event_add_free(void *data,
93 static void _ecore_exe_event_del_free(void *data,
95 static void _ecore_exe_event_exe_data_free(void *data,
97 static int _ecore_exe_win32_pipe_thread_generic_cb(void *data,
98 Ecore_Exe_Flags flags);
99 static DWORD WINAPI _ecore_exe_win32_pipe_thread_read_cb(void *data);
100 static DWORD WINAPI _ecore_exe_win32_pipe_thread_error_cb(void *data);
101 static Eina_Bool _ecore_exe_close_cb(void *data,
102 Ecore_Win32_Handler *wh);
103 static void _ecore_exe_pipe_read_cb(void *data,
106 static int _ecore_exe_pipe_write_cb(void *data,
107 Ecore_Win32_Handler *wh);
108 static void _ecore_exe_pipe_error_cb(void *data,
112 EAPI int ECORE_EXE_EVENT_ADD = 0;
113 EAPI int ECORE_EXE_EVENT_DEL = 0;
114 EAPI int ECORE_EXE_EVENT_DATA = 0;
115 EAPI int ECORE_EXE_EVENT_ERROR = 0;
118 _ecore_exe_init(void)
120 ECORE_EXE_EVENT_ADD = ecore_event_type_new();
121 ECORE_EXE_EVENT_DEL = ecore_event_type_new();
122 ECORE_EXE_EVENT_DATA = ecore_event_type_new();
123 ECORE_EXE_EVENT_ERROR = ecore_event_type_new();
127 _ecore_exe_shutdown(void)
130 ecore_exe_free(exes);
133 static int run_pri = NORMAL_PRIORITY_CLASS;
136 ecore_exe_run_priority_set(int pri)
140 case ECORE_EXE_WIN32_PRIORITY_IDLE:
141 run_pri = IDLE_PRIORITY_CLASS;
144 case ECORE_EXE_WIN32_PRIORITY_BELOW_NORMAL:
145 run_pri = BELOW_NORMAL_PRIORITY_CLASS;
148 case ECORE_EXE_WIN32_PRIORITY_NORMAL:
149 run_pri = NORMAL_PRIORITY_CLASS;
152 case ECORE_EXE_WIN32_PRIORITY_ABOVE_NORMAL:
153 run_pri = ABOVE_NORMAL_PRIORITY_CLASS;
156 case ECORE_EXE_WIN32_PRIORITY_HIGH:
157 run_pri = HIGH_PRIORITY_CLASS;
160 case ECORE_EXE_WIN32_PRIORITY_REALTIME:
161 run_pri = REALTIME_PRIORITY_CLASS;
170 ecore_exe_run_priority_get(void)
174 case IDLE_PRIORITY_CLASS:
175 return ECORE_EXE_WIN32_PRIORITY_IDLE;
177 case BELOW_NORMAL_PRIORITY_CLASS:
178 return ECORE_EXE_WIN32_PRIORITY_BELOW_NORMAL;
180 case NORMAL_PRIORITY_CLASS:
181 return ECORE_EXE_WIN32_PRIORITY_NORMAL;
183 case ABOVE_NORMAL_PRIORITY_CLASS:
184 return ECORE_EXE_WIN32_PRIORITY_ABOVE_NORMAL;
186 case HIGH_PRIORITY_CLASS:
187 return ECORE_EXE_WIN32_PRIORITY_HIGH;
189 case REALTIME_PRIORITY_CLASS:
190 return ECORE_EXE_WIN32_PRIORITY_REALTIME;
192 /* default should not be reached */
194 return ECORE_EXE_WIN32_PRIORITY_NORMAL;
199 ecore_exe_run(const char *exe_cmd,
202 return ecore_exe_pipe_run(exe_cmd, 0, data);
206 ecore_exe_pipe_run(const char *exe_cmd,
207 Ecore_Exe_Flags flags,
211 PROCESS_INFORMATION pi;
212 Ecore_Exe_Event_Add *e;
216 exe = calloc(1, sizeof(Ecore_Exe));
220 if ((flags & ECORE_EXE_PIPE_AUTO) && (!(flags & ECORE_EXE_PIPE_ERROR))
221 && (!(flags & ECORE_EXE_PIPE_READ)))
222 /* We need something to auto pipe. */
223 flags |= ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_ERROR;
226 if (exe->flags & ECORE_EXE_PIPE_READ)
227 if (!_ecore_exe_win32_pipes_set(exe))
230 if (exe->flags & ECORE_EXE_PIPE_WRITE)
231 if (!_ecore_exe_win32_pipes_set(exe))
234 if (exe->flags & ECORE_EXE_PIPE_ERROR)
235 if (!_ecore_exe_win32_pipes_set(exe))
238 if ((exe->flags & ECORE_EXE_USE_SH) ||
239 ((ret = strrstr(exe_cmd, ".bat")) && (ret[4] == '\0')))
242 snprintf(buf, PATH_MAX, "cmd.exe /c %s", exe_cmd);
243 exe->cmd = strdup(buf);
246 exe->cmd = strdup(exe_cmd);
251 ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
253 ZeroMemory(&si, sizeof(STARTUPINFO));
254 si.cb = sizeof(STARTUPINFO);
255 si.hStdOutput = exe->pipe_read.child_pipe_x;
256 si.hStdInput = exe->pipe_write.child_pipe;
257 si.hStdError = exe->pipe_error.child_pipe_x;
258 si.dwFlags |= STARTF_USESTDHANDLES;
260 /* FIXME: gerer la priorite */
262 if (!CreateProcess(NULL, exe->cmd, NULL, NULL, EINA_TRUE,
263 run_pri | CREATE_SUSPENDED, NULL, NULL, &si, &pi))
266 /* be sure that the child process is running */
267 /* FIXME: This does not work if the child is an EFL-based app */
268 /* if (WaitForInputIdle(pi.hProcess, INFINITE) == WAIT_FAILED) */
269 /* goto free_exe_cmd; */
271 ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE);
272 exe->process = pi.hProcess;
273 exe->process_thread = pi.hThread;
274 exe->process_id = pi.dwProcessId;
275 exe->thread_id = pi.dwThreadId;
276 exe->data = (void *)data;
278 if (!(exe->process2 = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_SUSPEND_RESUME | PROCESS_TERMINATE | SYNCHRONIZE,
279 EINA_FALSE, pi.dwProcessId)))
282 exe->h_close = ecore_main_win32_handler_add(exe->process2, _ecore_exe_close_cb, exe);
283 if (!exe->h_close) goto close_process2;
285 if (ResumeThread(exe->process_thread) == ((DWORD)-1))
288 exes = (Ecore_Exe *)eina_inlist_append(EINA_INLIST_GET(exes), EINA_INLIST_GET(exe));
290 e = (Ecore_Exe_Event_Add *)calloc(1, sizeof(Ecore_Exe_Event_Add));
291 if (!e) goto delete_h_close;
294 ecore_event_add(ECORE_EXE_EVENT_ADD, e,
295 _ecore_exe_event_add_free, NULL);
300 ecore_main_win32_handler_del(exe->h_close);
302 CloseHandle(exe->process2);
304 CloseHandle(exe->process_thread);
305 CloseHandle(exe->process);
309 _ecore_exe_win32_pipes_close(exe);
316 ecore_exe_callback_pre_free_set(Ecore_Exe *exe,
319 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
321 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
322 "ecore_exe_callback_pre_free_set");
325 exe->pre_free_cb = func;
329 ecore_exe_send(Ecore_Exe *exe,
335 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
337 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_send");
341 if (exe->close_stdin)
343 ERR("Ecore_Exe %p stdin is closed! Cannot send %d bytes from %p",
348 if (!exe->pipe_write.child_pipe)
350 ERR("Ecore_Exe %p created without ECORE_EXE_PIPE_WRITE! "
351 "Cannot send %d bytes from %p", exe, size, data);
355 buf = realloc(exe->pipe_write.data_buf, exe->pipe_write.data_size + size);
358 exe->pipe_write.data_buf = buf;
359 memcpy((char *)exe->pipe_write.data_buf + exe->pipe_write.data_size, data, size);
360 exe->pipe_write.data_size += size;
362 /* if (exe->pipe_write.) */
363 /* ecore_main_fd_handler_active_set(exe->pipe_write.h, ECORE_FD_WRITE); */
369 ecore_exe_close_stdin(Ecore_Exe *exe)
371 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
373 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_close_stdin");
376 exe->close_stdin = 1;
379 /* Not used on Windows */
381 ecore_exe_auto_limits_set(Ecore_Exe *exe __UNUSED__,
382 int start_bytes __UNUSED__,
383 int end_bytes __UNUSED__,
384 int start_lines __UNUSED__,
385 int end_lines __UNUSED__)
389 EAPI Ecore_Exe_Event_Data *
390 ecore_exe_event_data_get(Ecore_Exe *exe,
391 Ecore_Exe_Flags flags)
393 Ecore_Exe_Event_Data *e = NULL;
394 unsigned char *inbuf;
397 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
399 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_event_data_get");
403 /* Sort out what sort of event we are, */
404 /* And get the data. */
405 if (flags & ECORE_EXE_PIPE_READ)
407 inbuf = exe->pipe_read.data_buf;
408 inbuf_num = exe->pipe_read.data_size;
409 exe->pipe_read.data_buf = NULL;
410 exe->pipe_read.data_size = 0;
414 inbuf = exe->pipe_error.data_buf;
415 inbuf_num = exe->pipe_error.data_size;
416 exe->pipe_error.data_buf = NULL;
417 exe->pipe_error.data_size = 0;
420 e = calloc(1, sizeof(Ecore_Exe_Event_Data));
432 ecore_exe_event_data_free(Ecore_Exe_Event_Data *e)
441 ecore_exe_free(Ecore_Exe *exe)
445 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
447 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_free");
453 if (exe->pre_free_cb)
454 exe->pre_free_cb(data, exe);
456 CloseHandle(exe->process2);
457 CloseHandle(exe->process_thread);
458 CloseHandle(exe->process);
460 _ecore_exe_win32_pipes_close(exe);
461 exes = (Ecore_Exe *)eina_inlist_remove(EINA_INLIST_GET(exes), EINA_INLIST_GET(exe));
462 ECORE_MAGIC_SET(exe, ECORE_MAGIC_NONE);
463 if (exe->tag) free(exe->tag);
470 ecore_exe_pid_get(const Ecore_Exe *exe)
472 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
474 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pid_get");
477 return exe->process_id;
481 ecore_exe_tag_set(Ecore_Exe *exe,
484 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
486 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_tag_set");
491 exe->tag = strdup(tag);
495 ecore_exe_tag_get(const Ecore_Exe *exe)
497 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
499 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_tag_get");
506 ecore_exe_cmd_get(const Ecore_Exe *exe)
508 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
510 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_cmd_get");
517 ecore_exe_data_get(const Ecore_Exe *exe)
519 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
521 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get");
528 ecore_exe_flags_get(const Ecore_Exe *exe)
530 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
532 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get");
539 ecore_exe_pause(Ecore_Exe *exe)
541 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
543 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pause");
547 if (exe->is_suspended)
550 if (SuspendThread(exe->process_thread) != (DWORD)-1)
551 exe->is_suspended = 1;
555 ecore_exe_continue(Ecore_Exe *exe)
557 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
559 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_continue");
563 if (!exe->is_suspended)
566 if (ResumeThread(exe->process_thread) != (DWORD)-1)
567 exe->is_suspended = 0;
571 ecore_exe_interrupt(Ecore_Exe *exe)
573 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
575 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_interrupt");
579 CloseHandle(exe->process_thread);
580 CloseHandle(exe->process);
581 exe->sig = ECORE_EXE_WIN32_SIGINT;
582 while (EnumWindows(_ecore_exe_enum_windows_procedure, (LPARAM)exe)) ;
586 ecore_exe_quit(Ecore_Exe *exe)
588 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
590 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_quit");
594 CloseHandle(exe->process_thread);
595 CloseHandle(exe->process);
596 exe->sig = ECORE_EXE_WIN32_SIGQUIT;
597 while (EnumWindows(_ecore_exe_enum_windows_procedure, (LPARAM)exe)) ;
601 ecore_exe_terminate(Ecore_Exe *exe)
603 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
605 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_terminate");
609 /* CloseHandle(exe->thread); */
610 CloseHandle(exe->process);
611 exe->sig = ECORE_EXE_WIN32_SIGTERM;
612 while (EnumWindows(_ecore_exe_enum_windows_procedure, (LPARAM)exe)) ;
616 ecore_exe_kill(Ecore_Exe *exe)
618 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
620 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_kill");
624 CloseHandle(exe->process_thread);
625 CloseHandle(exe->process);
626 exe->sig = ECORE_EXE_WIN32_SIGKILL;
627 while (EnumWindows(_ecore_exe_enum_windows_procedure, (LPARAM)exe)) ;
631 ecore_exe_signal(Ecore_Exe *exe,
634 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
636 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_signal");
644 ecore_exe_hup(Ecore_Exe *exe)
646 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
648 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_hup");
655 /* FIXME: manage error mode */
657 _ecore_exe_win32_pipe_thread_generic_cb(void *data,
658 Ecore_Exe_Flags flags)
663 char *current_buf = NULL;
665 Ecore_Pipe *ecore_pipe;
666 Ecore_Exe_Event_Data *event;
668 DWORD current_size = 0;
671 exe = (Ecore_Exe *)data;
673 /* Sort out what sort of handler we are. */
674 /* And get any left over data from last time. */
675 if ((exe->flags & ECORE_EXE_PIPE_READ) && (flags == ECORE_EXE_PIPE_READ))
677 child_pipe = exe->pipe_read.child_pipe;
678 ecore_pipe = exe->pipe_read.p;
679 flags = ECORE_EXE_PIPE_READ;
681 else if ((exe->flags & ECORE_EXE_PIPE_ERROR) && (flags == ECORE_EXE_PIPE_ERROR))
683 child_pipe = exe->pipe_error.child_pipe;
684 ecore_pipe = exe->pipe_error.p;
685 flags = ECORE_EXE_PIPE_ERROR;
692 if (!PeekNamedPipe(child_pipe, buf, sizeof(buf), &size, ¤t_size, NULL))
696 current_buf = (char *)malloc(current_size);
699 res = ReadFile(child_pipe, current_buf, current_size, &size, NULL);
700 if (!res || (size == 0))
706 if (current_size != size)
714 if (flags == ECORE_EXE_PIPE_READ)
716 exe->pipe_read.data_buf = current_buf;
717 exe->pipe_read.data_size = current_size;
721 exe->pipe_error.data_buf = current_buf;
722 exe->pipe_error.data_size = current_size;
725 event = ecore_exe_event_data_get(exe, flags);
727 ecore_pipe_write(ecore_pipe, &event, sizeof(event));
737 _ecore_exe_win32_pipe_thread_read_cb(void *data)
739 return _ecore_exe_win32_pipe_thread_generic_cb(data, ECORE_EXE_PIPE_READ);
743 _ecore_exe_win32_pipe_thread_error_cb(void *data)
745 return _ecore_exe_win32_pipe_thread_generic_cb(data, ECORE_EXE_PIPE_ERROR);
749 _ecore_exe_win32_pipes_set(Ecore_Exe *exe)
751 SECURITY_ATTRIBUTES sa;
755 sa.nLength = sizeof(SECURITY_ATTRIBUTES);
756 sa.bInheritHandle = EINA_TRUE;
757 sa.lpSecurityDescriptor = NULL;
759 if (!CreatePipe(&child_pipe, &child_pipe_x, &sa, 0))
761 if (exe->flags & ECORE_EXE_PIPE_WRITE)
763 if (!SetHandleInformation(child_pipe_x, HANDLE_FLAG_INHERIT, 0))
768 if (!SetHandleInformation(child_pipe, HANDLE_FLAG_INHERIT, 0))
772 if (exe->flags & ECORE_EXE_PIPE_READ)
774 exe->pipe_read.child_pipe = child_pipe;
775 exe->pipe_read.child_pipe_x = child_pipe_x;
776 exe->pipe_read.p = ecore_pipe_add(_ecore_exe_pipe_read_cb, exe);
777 exe->pipe_read.thread = CreateThread(NULL, 0,
778 _ecore_exe_win32_pipe_thread_read_cb,
781 else if (exe->flags & ECORE_EXE_PIPE_WRITE)
783 exe->pipe_write.child_pipe = child_pipe;
784 exe->pipe_write.child_pipe_x = child_pipe_x;
785 /* exe->pipe_write.thread = CreateThread(NULL, 0, */
786 /* _ecore_exe_win32_pipe_thread_cb, */
791 exe->pipe_error.child_pipe = child_pipe;
792 exe->pipe_error.child_pipe_x = child_pipe_x;
793 exe->pipe_error.p = ecore_pipe_add(_ecore_exe_pipe_error_cb, exe);
794 exe->pipe_error.thread = CreateThread(NULL, 0,
795 _ecore_exe_win32_pipe_thread_error_cb,
802 CloseHandle(child_pipe);
803 CloseHandle(child_pipe_x);
809 _ecore_exe_win32_pipes_close(Ecore_Exe *exe)
811 if (exe->flags & ECORE_EXE_PIPE_READ)
813 if (exe->pipe_read.child_pipe)
815 CloseHandle(exe->pipe_read.child_pipe);
816 exe->pipe_read.child_pipe = NULL;
818 if (exe->pipe_read.child_pipe_x)
820 CloseHandle(exe->pipe_read.child_pipe_x);
821 exe->pipe_read.child_pipe_x = NULL;
825 if (exe->flags & ECORE_EXE_PIPE_WRITE)
827 if (exe->pipe_write.child_pipe)
829 CloseHandle(exe->pipe_write.child_pipe);
830 exe->pipe_write.child_pipe = NULL;
832 if (exe->pipe_write.child_pipe_x)
834 CloseHandle(exe->pipe_write.child_pipe_x);
835 exe->pipe_write.child_pipe_x = NULL;
839 if (exe->flags & ECORE_EXE_PIPE_ERROR)
841 if (exe->pipe_error.child_pipe)
843 CloseHandle(exe->pipe_error.child_pipe);
844 exe->pipe_error.child_pipe = NULL;
846 if (exe->pipe_error.child_pipe_x)
848 CloseHandle(exe->pipe_error.child_pipe_x);
849 exe->pipe_error.child_pipe_x = NULL;
855 _ecore_exe_thread_procedure(LPVOID data __UNUSED__)
857 GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
858 GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, 0);
863 _ecore_exe_enum_windows_procedure(HWND window,
869 exe = (Ecore_Exe *)data;
870 thread_id = GetWindowThreadProcessId(window, NULL);
872 if (thread_id == exe->thread_id)
874 /* Ctrl-C or Ctrl-Break */
875 if (CreateRemoteThread(exe->process, NULL, 0,
876 (LPTHREAD_START_ROUTINE)_ecore_exe_thread_procedure, NULL,
879 printf ("remote thread\n");
883 if ((exe->sig == ECORE_EXE_WIN32_SIGINT) ||
884 (exe->sig == ECORE_EXE_WIN32_SIGQUIT))
886 printf ("int or quit\n");
890 /* WM_CLOSE message */
891 PostMessage(window, WM_CLOSE, 0, 0);
892 if (WaitForSingleObject(exe->process, ECORE_EXE_WIN32_TIMEOUT) == WAIT_OBJECT_0)
898 /* WM_QUIT message */
899 PostMessage(window, WM_QUIT, 0, 0);
900 if (WaitForSingleObject(exe->process, ECORE_EXE_WIN32_TIMEOUT) == WAIT_OBJECT_0)
907 if (CreateRemoteThread(exe->process, NULL, 0,
908 (LPTHREAD_START_ROUTINE)ExitProcess, NULL,
911 printf ("remote thread 2\n");
915 if (exe->sig == ECORE_EXE_WIN32_SIGTERM)
921 TerminateProcess(exe->process, 0);
930 _ecore_exe_event_add_free(void *data __UNUSED__,
933 Ecore_Exe_Event_Add *e;
935 e = (Ecore_Exe_Event_Add *)ev;
940 _ecore_exe_event_del_free(void *data __UNUSED__,
943 Ecore_Exe_Event_Del *e;
945 e = (Ecore_Exe_Event_Del *)ev;
947 ecore_exe_free(e->exe);
952 _ecore_exe_event_exe_data_free(void *data __UNUSED__,
955 Ecore_Exe_Event_Data *e;
957 e = (Ecore_Exe_Event_Data *)ev;
958 ecore_exe_event_data_free(e);
962 _ecore_exe_close_cb(void *data,
963 Ecore_Win32_Handler *wh __UNUSED__)
965 Ecore_Exe_Event_Del *e;
969 e = calloc(1, sizeof(Ecore_Exe_Event_Del));
972 exe = (Ecore_Exe *)data;
974 if (GetExitCodeProcess(exe->process2, &exit_code))
976 e->exit_code = exit_code;
983 msg = evil_last_error_get();
987 e->pid = exe->process_id;
990 ecore_event_add(ECORE_EXE_EVENT_DEL, e,
991 _ecore_exe_event_del_free, NULL);
997 _ecore_exe_pipe_read_cb(void *data,
1001 Ecore_Exe_Event_Data *e;
1003 e = *((Ecore_Exe_Event_Data **)buf);
1005 ecore_event_add(ECORE_EXE_EVENT_DATA, e,
1006 _ecore_exe_event_exe_data_free,
1011 _ecore_exe_pipe_write_cb(void *data,
1012 Ecore_Win32_Handler *wh __UNUSED__)
1014 char buf[READBUFSIZ];
1019 exe = (Ecore_Exe *)data;
1021 res = WriteFile(exe->pipe_write.child_pipe_x, buf, READBUFSIZ, &num_exe, NULL);
1022 if (!res || num_exe == 0)
1024 /* FIXME: what to do here ?? */
1027 if (exe->close_stdin == 1)
1029 if (exe->pipe_write.h)
1031 ecore_main_win32_handler_del(exe->pipe_write.h);
1032 exe->pipe_write.h = NULL;
1034 exe->pipe_write.h = NULL;
1035 CloseHandle(exe->pipe_write.child_pipe);
1036 exe->pipe_write.child_pipe = NULL;
1043 _ecore_exe_pipe_error_cb(void *data,
1047 Ecore_Exe_Event_Data *e;
1049 e = *((Ecore_Exe_Event_Data **)buf);
1051 ecore_event_add(ECORE_EXE_EVENT_ERROR, e,
1052 _ecore_exe_event_exe_data_free,