2009-10-16 02:17:26 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2010-05-15 11:38:01 -07:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
|
|
|
#undef WIN32_LEAN_AND_MEAN
|
|
|
|
#include <process.h>
|
|
|
|
|
2014-04-25 03:23:41 -07:00
|
|
|
#include "Ecore.h"
|
|
|
|
#include "ecore_private.h"
|
|
|
|
|
2014-08-26 08:48:07 -07:00
|
|
|
#include "ecore_exe_private.h"
|
|
|
|
|
2014-04-25 03:23:41 -07:00
|
|
|
/*
|
|
|
|
* TESTS
|
|
|
|
*
|
|
|
|
* [X] add event
|
|
|
|
* [X] data event
|
|
|
|
* [X] error event
|
|
|
|
* [X] data event buffered
|
|
|
|
* [X] del event
|
|
|
|
* [ ] batch files
|
|
|
|
* [X] exit code
|
|
|
|
* [X] inherited env var
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FIXME :
|
|
|
|
*
|
|
|
|
* [ ] child program with ecore main loop does not exit and nothing is sent
|
|
|
|
* [ ] ecore_exe_send fails (race condition ? same problem as above ?)
|
|
|
|
*/
|
|
|
|
|
2009-10-16 02:17:26 -07:00
|
|
|
#define ECORE_EXE_WIN32_TIMEOUT 3000
|
|
|
|
|
2014-10-25 07:35:06 -07:00
|
|
|
static int run_pri = NORMAL_PRIORITY_CLASS;
|
2009-10-16 02:17:26 -07:00
|
|
|
|
2015-09-27 00:31:44 -07:00
|
|
|
static void
|
|
|
|
_ecore_exe_threads_terminate(Ecore_Exe *obj)
|
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
Ecore_Exe_Data *exe = efl_data_scope_get(obj, ECORE_EXE_CLASS);
|
2015-09-27 00:31:44 -07:00
|
|
|
HANDLE threads[2] = { NULL, NULL };
|
|
|
|
int i = 0;
|
|
|
|
|
2016-11-30 15:48:25 -08:00
|
|
|
if (!exe) return;
|
2015-09-27 00:31:44 -07:00
|
|
|
if (exe->pipe_read.thread)
|
|
|
|
{
|
|
|
|
threads[i] = exe->pipe_read.thread;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (exe->pipe_error.thread)
|
|
|
|
{
|
|
|
|
threads[i] = exe->pipe_error.thread;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (i > 0)
|
|
|
|
{
|
|
|
|
exe->close_threads = 1;
|
|
|
|
WaitForMultipleObjects(i, threads, TRUE, INFINITE);
|
2015-09-27 02:24:42 -07:00
|
|
|
IF_FN_DEL(CloseHandle, exe->pipe_error.thread);
|
|
|
|
IF_FN_DEL(CloseHandle, exe->pipe_read.thread);
|
2015-09-27 00:31:44 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-25 03:23:41 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_ecore_exe_close_cb(void *data,
|
|
|
|
Ecore_Win32_Handler *wh EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ecore_Exe_Event_Del *e;
|
2014-08-26 07:15:50 -07:00
|
|
|
Ecore_Exe *obj = data;
|
2016-08-15 06:44:41 -07:00
|
|
|
Ecore_Exe_Data *exe = efl_data_scope_get(obj, ECORE_EXE_CLASS);
|
2014-04-25 03:23:41 -07:00
|
|
|
DWORD exit_code = 0;
|
|
|
|
|
2016-11-30 15:48:25 -08:00
|
|
|
if (!exe) return 0;
|
2015-09-27 00:31:44 -07:00
|
|
|
_ecore_exe_threads_terminate(obj);
|
|
|
|
|
2014-04-25 03:23:41 -07:00
|
|
|
e = calloc(1, sizeof(Ecore_Exe_Event_Del));
|
|
|
|
if (!e) return 0;
|
|
|
|
|
|
|
|
/* FIXME : manage the STILL_ACTIVE returned error */
|
|
|
|
if (!GetExitCodeProcess(exe->process, &exit_code))
|
|
|
|
{
|
|
|
|
char *msg;
|
|
|
|
|
|
|
|
msg = evil_last_error_get();
|
|
|
|
printf("%s\n", msg);
|
|
|
|
free(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
e->exit_code = exit_code;
|
|
|
|
e->exited = 1;
|
2015-04-24 05:49:13 -07:00
|
|
|
e->pid = exe->pid;
|
2014-08-26 07:15:50 -07:00
|
|
|
e->exe = obj;
|
2015-10-13 06:31:29 -07:00
|
|
|
exe->h_close = NULL; // It's going to get deleted in the next callback.
|
2014-04-25 03:23:41 -07:00
|
|
|
|
|
|
|
ecore_event_add(ECORE_EXE_EVENT_DEL, e,
|
|
|
|
_ecore_exe_event_del_free, NULL);
|
|
|
|
|
|
|
|
DBG("Exiting process %s with exit code %d\n", exe->cmd, e->exit_code);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int __stdcall
|
|
|
|
_ecore_exe_pipe_read_thread_cb(void *data)
|
|
|
|
{
|
|
|
|
char buf[64];
|
2014-08-26 07:15:50 -07:00
|
|
|
Ecore_Exe *obj = data;
|
2016-08-15 06:44:41 -07:00
|
|
|
Ecore_Exe_Data *exe = efl_data_scope_get(obj, ECORE_EXE_CLASS);
|
2014-04-25 03:23:41 -07:00
|
|
|
Ecore_Exe_Event_Data *event_data;
|
|
|
|
char *current_buf = NULL;
|
|
|
|
DWORD size;
|
|
|
|
DWORD current_size = 0;
|
|
|
|
BOOL res;
|
|
|
|
|
2016-11-30 15:48:25 -08:00
|
|
|
if (!exe) return 0;
|
2015-09-27 00:31:44 -07:00
|
|
|
while (1)
|
2014-04-25 03:23:41 -07:00
|
|
|
{
|
2015-09-27 00:31:44 -07:00
|
|
|
res = PeekNamedPipe(exe->pipe_read.child_pipe,
|
|
|
|
buf, sizeof(buf) - 1, &size, ¤t_size, NULL);
|
|
|
|
if (!res || (size == 0))
|
|
|
|
{
|
|
|
|
if (exe->close_threads)
|
|
|
|
break;
|
|
|
|
|
2015-10-06 20:54:41 -07:00
|
|
|
Sleep(100);
|
2015-09-27 00:31:44 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-04-25 03:23:41 -07:00
|
|
|
current_buf = (char *)malloc(current_size);
|
|
|
|
if (!current_buf)
|
|
|
|
continue;
|
2015-09-27 00:31:44 -07:00
|
|
|
|
2014-04-25 03:23:41 -07:00
|
|
|
res = ReadFile(exe->pipe_read.child_pipe, current_buf, current_size, &size, NULL);
|
|
|
|
if (!res || (size == 0))
|
|
|
|
{
|
|
|
|
free(current_buf);
|
|
|
|
current_buf = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
2015-09-27 00:31:44 -07:00
|
|
|
|
|
|
|
current_size = size;
|
|
|
|
|
|
|
|
if (!exe->pipe_read.data_buf)
|
2014-04-25 03:23:41 -07:00
|
|
|
{
|
2015-09-27 00:31:44 -07:00
|
|
|
exe->pipe_read.data_buf = current_buf;
|
|
|
|
exe->pipe_read.data_size = current_size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
exe->pipe_read.data_buf = realloc(exe->pipe_read.data_buf, exe->pipe_read.data_size + current_size);
|
|
|
|
memcpy((unsigned char *)exe->pipe_read.data_buf + exe->pipe_read.data_size, current_buf, current_size);
|
|
|
|
exe->pipe_read.data_size += current_size;
|
2014-04-25 03:23:41 -07:00
|
|
|
free(current_buf);
|
|
|
|
}
|
|
|
|
|
2014-08-26 07:15:50 -07:00
|
|
|
event_data = ecore_exe_event_data_get(obj, ECORE_EXE_PIPE_READ);
|
2014-04-25 03:23:41 -07:00
|
|
|
if (event_data)
|
|
|
|
{
|
|
|
|
ecore_event_add(ECORE_EXE_EVENT_DATA, event_data,
|
|
|
|
_ecore_exe_event_exe_data_free,
|
|
|
|
NULL);
|
2016-08-29 16:13:22 -07:00
|
|
|
efl_event_callback_call(obj, ECORE_EXE_EVENT_DATA_GET, event_data);
|
2014-04-25 03:23:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
current_buf = NULL;
|
|
|
|
current_size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_endthreadex(0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int __stdcall
|
|
|
|
_ecore_exe_pipe_error_thread_cb(void *data)
|
|
|
|
{
|
|
|
|
char buf[64];
|
2014-08-26 07:15:50 -07:00
|
|
|
Ecore_Exe *obj = data;
|
2016-08-15 06:44:41 -07:00
|
|
|
Ecore_Exe_Data *exe = efl_data_scope_get(obj, ECORE_EXE_CLASS);
|
2014-04-25 03:23:41 -07:00
|
|
|
Ecore_Exe_Event_Data *event_data;
|
|
|
|
char *current_buf = NULL;
|
|
|
|
DWORD size;
|
|
|
|
DWORD current_size = 0;
|
|
|
|
BOOL res;
|
|
|
|
|
2016-11-30 15:48:25 -08:00
|
|
|
if (!exe) return 0;
|
2015-09-27 00:31:44 -07:00
|
|
|
while (1)
|
2014-04-25 03:23:41 -07:00
|
|
|
{
|
2015-09-27 00:31:44 -07:00
|
|
|
res = PeekNamedPipe(exe->pipe_error.child_pipe,
|
|
|
|
buf, sizeof(buf) - 1, &size, ¤t_size, NULL);
|
|
|
|
if (!res || (size == 0))
|
|
|
|
{
|
|
|
|
if (exe->close_threads)
|
|
|
|
break;
|
|
|
|
|
2015-10-06 20:54:41 -07:00
|
|
|
Sleep(100);
|
2015-09-27 00:31:44 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-04-25 03:23:41 -07:00
|
|
|
current_buf = (char *)malloc(current_size);
|
|
|
|
if (!current_buf)
|
|
|
|
continue;
|
2015-09-27 00:31:44 -07:00
|
|
|
|
2014-04-25 03:23:41 -07:00
|
|
|
res = ReadFile(exe->pipe_error.child_pipe, current_buf, current_size, &size, NULL);
|
|
|
|
if (!res || (size == 0))
|
|
|
|
{
|
|
|
|
free(current_buf);
|
|
|
|
current_buf = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
2015-09-27 00:31:44 -07:00
|
|
|
|
|
|
|
current_size = size;
|
|
|
|
|
|
|
|
if (!exe->pipe_error.data_buf)
|
|
|
|
{
|
|
|
|
exe->pipe_error.data_buf = current_buf;
|
|
|
|
exe->pipe_error.data_size = current_size;
|
|
|
|
}
|
|
|
|
else
|
2014-04-25 03:23:41 -07:00
|
|
|
{
|
2015-09-27 00:31:44 -07:00
|
|
|
exe->pipe_error.data_buf = realloc(exe->pipe_error.data_buf, exe->pipe_error.data_size + current_size);
|
|
|
|
memcpy((unsigned char *)exe->pipe_error.data_buf + exe->pipe_error.data_size, current_buf, current_size);
|
|
|
|
exe->pipe_error.data_size += current_size;
|
2014-04-25 03:23:41 -07:00
|
|
|
free(current_buf);
|
|
|
|
}
|
|
|
|
|
2014-08-26 07:15:50 -07:00
|
|
|
event_data = ecore_exe_event_data_get(obj, ECORE_EXE_PIPE_ERROR);
|
2014-04-25 03:23:41 -07:00
|
|
|
if (event_data)
|
|
|
|
{
|
|
|
|
ecore_event_add(ECORE_EXE_EVENT_ERROR, event_data,
|
|
|
|
_ecore_exe_event_exe_data_free,
|
|
|
|
NULL);
|
2016-08-29 16:13:22 -07:00
|
|
|
efl_event_callback_call(obj, ECORE_EXE_EVENT_DATA_ERROR, event_data);
|
2014-04-25 03:23:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
current_buf = NULL;
|
|
|
|
current_size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_endthreadex(0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD WINAPI
|
|
|
|
_ecore_exe_thread_procedure(LPVOID data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
|
|
|
|
GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, 0);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL CALLBACK
|
|
|
|
_ecore_exe_enum_windows_procedure(HWND window,
|
|
|
|
LPARAM data)
|
|
|
|
{
|
2014-08-26 08:48:07 -07:00
|
|
|
Ecore_Exe *obj = (Ecore_Exe *) data;
|
2016-08-15 06:44:41 -07:00
|
|
|
Ecore_Exe_Data *exe = efl_data_scope_get(obj, ECORE_EXE_CLASS);
|
2014-04-25 03:23:41 -07:00
|
|
|
DWORD thread_id;
|
|
|
|
|
2016-11-30 15:48:25 -08:00
|
|
|
if (!exe) return EINA_FALSE;
|
2014-04-25 03:23:41 -07:00
|
|
|
thread_id = GetWindowThreadProcessId(window, NULL);
|
|
|
|
|
|
|
|
if (thread_id == exe->thread_id)
|
|
|
|
{
|
|
|
|
/* Ctrl-C or Ctrl-Break */
|
|
|
|
if (CreateRemoteThread(exe->process, NULL, 0,
|
|
|
|
(LPTHREAD_START_ROUTINE)_ecore_exe_thread_procedure, NULL,
|
|
|
|
0, NULL))
|
|
|
|
{
|
|
|
|
printf ("remote thread\n");
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((exe->sig == ECORE_EXE_WIN32_SIGINT) ||
|
|
|
|
(exe->sig == ECORE_EXE_WIN32_SIGQUIT))
|
|
|
|
{
|
|
|
|
printf ("int or quit\n");
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* WM_CLOSE message */
|
|
|
|
PostMessage(window, WM_CLOSE, 0, 0);
|
|
|
|
if (WaitForSingleObject(exe->process, ECORE_EXE_WIN32_TIMEOUT) == WAIT_OBJECT_0)
|
|
|
|
{
|
|
|
|
printf ("CLOSE\n");
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* WM_QUIT message */
|
|
|
|
PostMessage(window, WM_QUIT, 0, 0);
|
|
|
|
if (WaitForSingleObject(exe->process, ECORE_EXE_WIN32_TIMEOUT) == WAIT_OBJECT_0)
|
|
|
|
{
|
|
|
|
printf ("QUIT\n");
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Exit process */
|
|
|
|
if (CreateRemoteThread(exe->process, NULL, 0,
|
|
|
|
(LPTHREAD_START_ROUTINE)ExitProcess, NULL,
|
|
|
|
0, NULL))
|
|
|
|
{
|
|
|
|
printf ("remote thread 2\n");
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (exe->sig == ECORE_EXE_WIN32_SIGTERM)
|
|
|
|
{
|
|
|
|
printf ("term\n");
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
TerminateProcess(exe->process, 0);
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2009-10-16 02:17:26 -07:00
|
|
|
|
|
|
|
void
|
2014-08-27 03:00:11 -07:00
|
|
|
_impl_ecore_exe_run_priority_set(int pri)
|
2009-10-16 02:17:26 -07:00
|
|
|
{
|
2010-02-20 01:20:04 -08:00
|
|
|
switch (pri)
|
|
|
|
{
|
2011-10-20 22:40:39 -07:00
|
|
|
case ECORE_EXE_WIN32_PRIORITY_IDLE:
|
|
|
|
run_pri = IDLE_PRIORITY_CLASS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ECORE_EXE_WIN32_PRIORITY_BELOW_NORMAL:
|
|
|
|
run_pri = BELOW_NORMAL_PRIORITY_CLASS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ECORE_EXE_WIN32_PRIORITY_NORMAL:
|
|
|
|
run_pri = NORMAL_PRIORITY_CLASS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ECORE_EXE_WIN32_PRIORITY_ABOVE_NORMAL:
|
|
|
|
run_pri = ABOVE_NORMAL_PRIORITY_CLASS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ECORE_EXE_WIN32_PRIORITY_HIGH:
|
|
|
|
run_pri = HIGH_PRIORITY_CLASS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ECORE_EXE_WIN32_PRIORITY_REALTIME:
|
|
|
|
run_pri = REALTIME_PRIORITY_CLASS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2010-02-20 01:20:04 -08:00
|
|
|
}
|
2009-10-16 02:17:26 -07:00
|
|
|
}
|
|
|
|
|
2014-08-26 08:48:07 -07:00
|
|
|
int
|
2014-08-27 03:00:11 -07:00
|
|
|
_impl_ecore_exe_run_priority_get(void)
|
2009-10-16 02:17:26 -07:00
|
|
|
{
|
2010-02-20 01:20:04 -08:00
|
|
|
switch (run_pri)
|
|
|
|
{
|
2011-10-20 22:40:39 -07:00
|
|
|
case IDLE_PRIORITY_CLASS:
|
|
|
|
return ECORE_EXE_WIN32_PRIORITY_IDLE;
|
|
|
|
|
|
|
|
case BELOW_NORMAL_PRIORITY_CLASS:
|
|
|
|
return ECORE_EXE_WIN32_PRIORITY_BELOW_NORMAL;
|
|
|
|
|
|
|
|
case NORMAL_PRIORITY_CLASS:
|
|
|
|
return ECORE_EXE_WIN32_PRIORITY_NORMAL;
|
|
|
|
|
|
|
|
case ABOVE_NORMAL_PRIORITY_CLASS:
|
|
|
|
return ECORE_EXE_WIN32_PRIORITY_ABOVE_NORMAL;
|
|
|
|
|
|
|
|
case HIGH_PRIORITY_CLASS:
|
|
|
|
return ECORE_EXE_WIN32_PRIORITY_HIGH;
|
|
|
|
|
|
|
|
case REALTIME_PRIORITY_CLASS:
|
|
|
|
return ECORE_EXE_WIN32_PRIORITY_REALTIME;
|
|
|
|
|
|
|
|
/* default should not be reached */
|
|
|
|
default:
|
|
|
|
return ECORE_EXE_WIN32_PRIORITY_NORMAL;
|
2010-02-20 01:20:04 -08:00
|
|
|
}
|
2009-10-16 02:17:26 -07:00
|
|
|
}
|
|
|
|
|
2014-08-26 08:48:07 -07:00
|
|
|
Eo *
|
2016-08-10 07:23:04 -07:00
|
|
|
_impl_ecore_exe_efl_object_finalize(Eo *obj, Ecore_Exe_Data *exe)
|
2009-10-16 02:17:26 -07:00
|
|
|
{
|
2015-09-27 04:27:15 -07:00
|
|
|
char exe_cmd_buf[32768];
|
2014-04-25 03:23:41 -07:00
|
|
|
SECURITY_ATTRIBUTES sa;
|
2011-10-20 22:40:39 -07:00
|
|
|
STARTUPINFO si;
|
2015-09-27 04:27:15 -07:00
|
|
|
PROCESS_INFORMATION pi;
|
2015-09-29 14:47:10 -07:00
|
|
|
HANDLE child_pipe_read = NULL;
|
|
|
|
HANDLE child_pipe_error = NULL;
|
2015-09-27 04:27:15 -07:00
|
|
|
const char *shell = NULL;
|
2014-04-25 03:23:41 -07:00
|
|
|
Ecore_Exe_Event_Add *e;
|
2015-09-27 04:27:15 -07:00
|
|
|
Ecore_Exe_Flags flags;
|
2014-04-25 03:23:41 -07:00
|
|
|
Eina_Bool use_sh = EINA_FALSE;
|
|
|
|
|
|
|
|
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
|
|
|
|
|
2015-09-27 04:27:15 -07:00
|
|
|
flags = exe->flags;
|
2009-10-16 02:17:26 -07:00
|
|
|
|
2015-10-06 20:54:41 -07:00
|
|
|
DBG("Creating process %s with flags %d", exe->cmd, flags);
|
2015-09-27 04:27:15 -07:00
|
|
|
|
|
|
|
if (!exe->cmd) goto error;
|
2015-08-29 00:46:22 -07:00
|
|
|
|
2009-12-06 11:25:48 -08:00
|
|
|
if ((flags & ECORE_EXE_PIPE_AUTO) && (!(flags & ECORE_EXE_PIPE_ERROR))
|
|
|
|
&& (!(flags & ECORE_EXE_PIPE_READ)))
|
|
|
|
/* We need something to auto pipe. */
|
|
|
|
flags |= ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_ERROR;
|
|
|
|
|
2014-04-25 03:23:41 -07:00
|
|
|
if ((flags & ECORE_EXE_USE_SH))
|
|
|
|
use_sh = EINA_TRUE;
|
|
|
|
else
|
2015-09-27 04:27:15 -07:00
|
|
|
use_sh = eina_str_has_extension(exe->cmd, ".bat");
|
2010-02-19 11:23:47 -08:00
|
|
|
|
2014-04-25 03:23:41 -07:00
|
|
|
if (use_sh)
|
2009-10-16 02:17:26 -07:00
|
|
|
{
|
2014-04-25 03:23:41 -07:00
|
|
|
int len;
|
|
|
|
|
|
|
|
shell = "cmd.exe";
|
2015-09-27 04:27:15 -07:00
|
|
|
len = snprintf(exe_cmd_buf, sizeof(exe_cmd_buf), "/c %s", exe->cmd);
|
2014-04-25 03:23:41 -07:00
|
|
|
if (len >= (int)sizeof(exe_cmd_buf))
|
|
|
|
exe_cmd_buf[sizeof(exe_cmd_buf) - 1] = '\0';
|
2009-10-16 02:17:26 -07:00
|
|
|
}
|
|
|
|
else
|
2014-04-25 03:23:41 -07:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
/* FIXME : faster with memset() but one must be careful with size */
|
2015-09-27 04:27:15 -07:00
|
|
|
len = snprintf(exe_cmd_buf, sizeof(exe_cmd_buf), "%s", exe->cmd);
|
2014-04-25 03:23:41 -07:00
|
|
|
if (len >= (int)sizeof(exe_cmd_buf))
|
|
|
|
exe_cmd_buf[sizeof(exe_cmd_buf) - 1] = '\0';
|
|
|
|
}
|
2009-10-16 02:17:26 -07:00
|
|
|
|
2014-04-25 03:23:41 -07:00
|
|
|
/* stdout, stderr and stdin pipes */
|
|
|
|
|
|
|
|
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
|
|
|
|
sa.bInheritHandle = EINA_TRUE;
|
|
|
|
sa.lpSecurityDescriptor = NULL;
|
|
|
|
|
|
|
|
/* stdout pipe */
|
|
|
|
if (exe->flags & ECORE_EXE_PIPE_READ)
|
|
|
|
{
|
2015-09-27 01:08:26 -07:00
|
|
|
if (!CreatePipe(&exe->pipe_read.child_pipe, &child_pipe_read, &sa, 0))
|
2015-07-07 03:36:06 -07:00
|
|
|
goto error;
|
2014-04-25 03:23:41 -07:00
|
|
|
if (!SetHandleInformation(exe->pipe_read.child_pipe, HANDLE_FLAG_INHERIT, 0))
|
2015-07-07 03:36:06 -07:00
|
|
|
goto error;
|
2014-04-25 03:23:41 -07:00
|
|
|
exe->pipe_read.thread = (HANDLE)_beginthreadex(NULL, 0,
|
|
|
|
_ecore_exe_pipe_read_thread_cb,
|
2015-03-18 03:05:20 -07:00
|
|
|
obj, 0, NULL);
|
2014-04-25 03:23:41 -07:00
|
|
|
if (!exe->pipe_read.thread)
|
2015-07-07 03:36:06 -07:00
|
|
|
goto error;
|
2014-04-25 03:23:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stderr pipe */
|
|
|
|
if (exe->flags & ECORE_EXE_PIPE_ERROR)
|
|
|
|
{
|
2015-09-27 01:08:26 -07:00
|
|
|
if (!CreatePipe(&exe->pipe_error.child_pipe, &child_pipe_error, &sa, 0))
|
2015-07-07 03:36:06 -07:00
|
|
|
goto error;
|
2014-04-25 03:23:41 -07:00
|
|
|
if (!SetHandleInformation(exe->pipe_error.child_pipe, HANDLE_FLAG_INHERIT, 0))
|
2015-07-07 03:36:06 -07:00
|
|
|
goto error;
|
2014-04-25 03:23:41 -07:00
|
|
|
exe->pipe_error.thread = (HANDLE)_beginthreadex(NULL, 0,
|
|
|
|
_ecore_exe_pipe_error_thread_cb,
|
2015-03-18 03:05:20 -07:00
|
|
|
obj, 0, NULL);
|
2014-04-25 03:23:41 -07:00
|
|
|
if (!exe->pipe_error.thread)
|
2015-07-07 03:36:06 -07:00
|
|
|
goto error;
|
2014-04-25 03:23:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stdin pipe */
|
|
|
|
if (exe->flags & ECORE_EXE_PIPE_WRITE)
|
|
|
|
{
|
|
|
|
if (!CreatePipe(&exe->pipe_write.child_pipe, &exe->pipe_write.child_pipe_x, &sa, 0))
|
2015-07-07 03:36:06 -07:00
|
|
|
goto error;
|
2014-04-25 03:23:41 -07:00
|
|
|
if (!SetHandleInformation(exe->pipe_write.child_pipe_x, HANDLE_FLAG_INHERIT, 0))
|
2015-07-07 03:36:06 -07:00
|
|
|
goto error;
|
2014-04-25 03:23:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* create child process */
|
2009-10-16 02:17:26 -07:00
|
|
|
|
|
|
|
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
|
|
|
|
|
|
|
|
ZeroMemory(&si, sizeof(STARTUPINFO));
|
2009-12-06 11:25:48 -08:00
|
|
|
si.cb = sizeof(STARTUPINFO);
|
2015-09-27 01:08:26 -07:00
|
|
|
si.hStdOutput = child_pipe_read;
|
2010-02-19 11:23:47 -08:00
|
|
|
si.hStdInput = exe->pipe_write.child_pipe;
|
2015-09-27 01:08:26 -07:00
|
|
|
si.hStdError = child_pipe_error;
|
2009-12-06 11:25:48 -08:00
|
|
|
si.dwFlags |= STARTF_USESTDHANDLES;
|
2009-10-16 02:17:26 -07:00
|
|
|
|
2015-09-27 04:27:15 -07:00
|
|
|
DBG("CreateProcess: shell:%s child:%s", use_sh ? "yes" : "no", exe_cmd_buf);
|
|
|
|
if (!CreateProcess(shell, exe_cmd_buf, NULL, NULL, EINA_TRUE,
|
2010-02-20 01:20:04 -08:00
|
|
|
run_pri | CREATE_SUSPENDED, NULL, NULL, &si, &pi))
|
2014-04-25 03:23:41 -07:00
|
|
|
{
|
2015-09-27 01:18:54 -07:00
|
|
|
char *msg;
|
|
|
|
|
|
|
|
msg = evil_last_error_get();
|
|
|
|
if (msg)
|
|
|
|
{
|
2015-09-27 04:27:15 -07:00
|
|
|
WRN("Failed to create process %s: %s", exe_cmd_buf, msg);
|
2015-09-27 01:18:54 -07:00
|
|
|
free(msg);
|
|
|
|
}
|
|
|
|
else
|
2015-09-27 04:27:15 -07:00
|
|
|
WRN("Failed to create process %s: %ld", exe_cmd_buf, GetLastError());
|
2015-07-07 03:36:06 -07:00
|
|
|
goto error;
|
2014-04-25 03:23:41 -07:00
|
|
|
}
|
2009-10-16 02:17:26 -07:00
|
|
|
|
2015-09-27 01:08:26 -07:00
|
|
|
/*
|
|
|
|
* Close pipe handles (do not continue to modify the parent).
|
|
|
|
* We need to make sure that no handles to the write end of the
|
|
|
|
* output and error pipes are maintained in this process or else
|
|
|
|
* the pipe will not close when the child process exits and the
|
|
|
|
* ReadFile will hang.
|
|
|
|
*/
|
2015-09-29 14:47:10 -07:00
|
|
|
IF_FN_DEL(CloseHandle, child_pipe_read);
|
|
|
|
IF_FN_DEL(CloseHandle, child_pipe_error);
|
2015-09-27 01:08:26 -07:00
|
|
|
|
2009-10-25 01:23:28 -07:00
|
|
|
/* be sure that the child process is running */
|
2009-11-08 14:19:30 -08:00
|
|
|
/* FIXME: This does not work if the child is an EFL-based app */
|
2010-05-15 11:38:01 -07:00
|
|
|
/* if (WaitForInputIdle(pi.hProcess, INFINITE) == WAIT_FAILED) */
|
2015-07-07 03:36:06 -07:00
|
|
|
/* goto error; */
|
2009-10-25 01:23:28 -07:00
|
|
|
|
2009-11-08 14:19:30 -08:00
|
|
|
exe->process = pi.hProcess;
|
2010-05-15 11:38:01 -07:00
|
|
|
exe->process_thread = pi.hThread;
|
2015-03-23 11:37:21 -07:00
|
|
|
exe->pid = pi.dwProcessId;
|
2009-10-16 02:17:26 -07:00
|
|
|
exe->thread_id = pi.dwThreadId;
|
|
|
|
|
2014-04-25 03:23:41 -07:00
|
|
|
exe->h_close = ecore_main_win32_handler_add(exe->process,
|
2014-08-26 07:15:50 -07:00
|
|
|
_ecore_exe_close_cb, obj);
|
2014-04-25 03:23:41 -07:00
|
|
|
if (!exe->h_close)
|
2015-07-07 03:36:06 -07:00
|
|
|
goto error;
|
2009-11-08 14:19:30 -08:00
|
|
|
|
2010-05-15 11:38:01 -07:00
|
|
|
if (ResumeThread(exe->process_thread) == ((DWORD)-1))
|
2014-04-25 03:23:41 -07:00
|
|
|
{
|
|
|
|
ERR("Could not resume process");
|
2015-07-07 03:36:06 -07:00
|
|
|
goto error;
|
2014-04-25 03:23:41 -07:00
|
|
|
}
|
2010-05-15 11:38:01 -07:00
|
|
|
|
2014-08-27 03:00:11 -07:00
|
|
|
_ecore_exe_exes = eina_list_append(_ecore_exe_exes, obj);
|
2009-11-08 14:19:30 -08:00
|
|
|
|
|
|
|
e = (Ecore_Exe_Event_Add *)calloc(1, sizeof(Ecore_Exe_Event_Add));
|
2015-07-07 03:36:06 -07:00
|
|
|
if (!e) goto error;
|
2009-11-08 14:19:30 -08:00
|
|
|
|
2014-08-26 07:15:50 -07:00
|
|
|
e->exe = obj;
|
2014-04-25 03:23:41 -07:00
|
|
|
|
2009-11-08 14:19:30 -08:00
|
|
|
ecore_event_add(ECORE_EXE_EVENT_ADD, e,
|
|
|
|
_ecore_exe_event_add_free, NULL);
|
|
|
|
|
2014-08-26 07:15:50 -07:00
|
|
|
return obj;
|
2009-10-16 02:17:26 -07:00
|
|
|
|
2015-07-07 03:36:06 -07:00
|
|
|
error:
|
2009-10-16 02:17:26 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-08-26 08:48:07 -07:00
|
|
|
Eina_Bool
|
2014-08-27 03:00:11 -07:00
|
|
|
_impl_ecore_exe_send(Ecore_Exe *obj,
|
2014-08-26 08:48:07 -07:00
|
|
|
Ecore_Exe_Data *exe,
|
2011-10-20 22:40:39 -07:00
|
|
|
const void *data,
|
|
|
|
int size)
|
2009-10-16 02:17:26 -07:00
|
|
|
{
|
2014-04-25 03:23:41 -07:00
|
|
|
void *buf = NULL;
|
|
|
|
DWORD num_exe;
|
|
|
|
BOOL res;
|
2010-05-15 11:38:01 -07:00
|
|
|
|
|
|
|
buf = realloc(exe->pipe_write.data_buf, exe->pipe_write.data_size + size);
|
2014-04-25 03:23:41 -07:00
|
|
|
if (!buf) return EINA_FALSE;
|
2010-05-15 11:38:01 -07:00
|
|
|
|
|
|
|
exe->pipe_write.data_buf = buf;
|
|
|
|
memcpy((char *)exe->pipe_write.data_buf + exe->pipe_write.data_size, data, size);
|
|
|
|
exe->pipe_write.data_size += size;
|
|
|
|
|
2014-04-25 03:23:41 -07:00
|
|
|
res = WriteFile(exe->pipe_write.child_pipe_x, buf, READBUFSIZ, &num_exe, NULL);
|
|
|
|
printf(" ** res : %d\n", res);
|
|
|
|
if (!res || num_exe == 0)
|
|
|
|
{
|
|
|
|
ERR("Ecore_Exe %p stdin is closed! Cannot send %d bytes from %p",
|
2014-08-26 07:15:50 -07:00
|
|
|
obj, size, data);
|
2014-04-25 03:23:41 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2010-05-15 11:38:01 -07:00
|
|
|
|
2014-04-25 03:23:41 -07:00
|
|
|
return EINA_TRUE;
|
2009-10-16 02:17:26 -07:00
|
|
|
}
|
|
|
|
|
2014-08-26 08:48:07 -07:00
|
|
|
Ecore_Exe_Event_Data *
|
2014-08-27 03:00:11 -07:00
|
|
|
_impl_ecore_exe_event_data_get(Ecore_Exe *obj,
|
2014-08-26 08:48:07 -07:00
|
|
|
Ecore_Exe_Data *exe,
|
2011-10-20 22:40:39 -07:00
|
|
|
Ecore_Exe_Flags flags)
|
2009-10-16 02:17:26 -07:00
|
|
|
{
|
2009-12-06 11:25:48 -08:00
|
|
|
Ecore_Exe_Event_Data *e = NULL;
|
2011-10-20 22:40:39 -07:00
|
|
|
unsigned char *inbuf;
|
2014-04-25 03:23:41 -07:00
|
|
|
DWORD inbuf_num;
|
|
|
|
Eina_Bool is_buffered = EINA_FALSE;
|
2009-12-06 11:25:48 -08:00
|
|
|
|
2014-04-25 03:23:41 -07:00
|
|
|
/* Sort out what sort of event we are. */
|
2009-12-06 11:25:48 -08:00
|
|
|
if (flags & ECORE_EXE_PIPE_READ)
|
2014-04-25 03:23:41 -07:00
|
|
|
{
|
|
|
|
flags = ECORE_EXE_PIPE_READ;
|
|
|
|
if (exe->flags & ECORE_EXE_PIPE_READ_LINE_BUFFERED)
|
|
|
|
is_buffered = EINA_TRUE;
|
|
|
|
}
|
2009-12-06 11:25:48 -08:00
|
|
|
else
|
2014-04-25 03:23:41 -07:00
|
|
|
{
|
|
|
|
flags = ECORE_EXE_PIPE_ERROR;
|
|
|
|
if (exe->flags & ECORE_EXE_PIPE_ERROR_LINE_BUFFERED)
|
|
|
|
is_buffered = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the data. */
|
|
|
|
if (flags & ECORE_EXE_PIPE_READ)
|
|
|
|
{
|
|
|
|
inbuf = exe->pipe_read.data_buf;
|
|
|
|
inbuf_num = exe->pipe_read.data_size;
|
|
|
|
exe->pipe_read.data_buf = NULL;
|
|
|
|
exe->pipe_read.data_size = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inbuf = exe->pipe_error.data_buf;
|
|
|
|
inbuf_num = exe->pipe_error.data_size;
|
|
|
|
exe->pipe_error.data_buf = NULL;
|
|
|
|
exe->pipe_error.data_size = 0;
|
|
|
|
}
|
2009-12-06 11:25:48 -08:00
|
|
|
|
|
|
|
e = calloc(1, sizeof(Ecore_Exe_Event_Data));
|
|
|
|
if (e)
|
2014-04-25 03:23:41 -07:00
|
|
|
{
|
2014-08-26 07:15:50 -07:00
|
|
|
e->exe = obj;
|
2014-04-25 03:23:41 -07:00
|
|
|
e->data = inbuf;
|
|
|
|
e->size = inbuf_num;
|
|
|
|
|
|
|
|
if (is_buffered) /* Deal with line buffering. */
|
|
|
|
{
|
|
|
|
char *c;
|
|
|
|
DWORD i;
|
|
|
|
DWORD max = 0;
|
|
|
|
DWORD count = 0;
|
|
|
|
DWORD last = 0;
|
|
|
|
|
|
|
|
c = (char *)inbuf;
|
|
|
|
for (i = 0; i < inbuf_num; i++)
|
|
|
|
{
|
|
|
|
if (inbuf[i] == '\n')
|
|
|
|
{
|
|
|
|
int end;
|
|
|
|
|
|
|
|
if (count >= max)
|
|
|
|
{
|
|
|
|
max += 10;
|
|
|
|
e->lines = realloc(e->lines, sizeof(Ecore_Exe_Event_Data_Line) * (max + 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((i >= 1) && (inbuf[i - 1] == '\r'))
|
|
|
|
end = i - 1;
|
|
|
|
else
|
|
|
|
end = i;
|
|
|
|
inbuf[end] = '\0';
|
|
|
|
e->lines[count].line = c;
|
|
|
|
e->lines[count].size = end - last;
|
|
|
|
last = i + 1;
|
|
|
|
c = (char *)&inbuf[last];
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i > last) /* Partial line left over, save it for next time. */
|
|
|
|
{
|
|
|
|
if (count != 0) e->size = last;
|
|
|
|
if (flags & ECORE_EXE_PIPE_READ)
|
|
|
|
{
|
|
|
|
exe->pipe_read.data_size = i - last;
|
|
|
|
exe->pipe_read.data_buf = malloc(exe->pipe_read.data_size);
|
|
|
|
memcpy(exe->pipe_read.data_buf, c, exe->pipe_read.data_size);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
exe->pipe_error.data_size = i - last;
|
|
|
|
exe->pipe_error.data_buf = malloc(exe->pipe_error.data_size);
|
|
|
|
memcpy(exe->pipe_error.data_buf, c, exe->pipe_error.data_size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (count == 0) /* No lines to send, cancel the event. */
|
|
|
|
{
|
|
|
|
_ecore_exe_event_exe_data_free(NULL, e);
|
|
|
|
e = NULL;
|
|
|
|
}
|
|
|
|
else /* NULL terminate the array, so that people know where the end is. */
|
|
|
|
{
|
|
|
|
e->lines[count].line = NULL;
|
|
|
|
e->lines[count].size = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-12-06 11:25:48 -08:00
|
|
|
|
|
|
|
return e;
|
2009-10-16 02:17:26 -07:00
|
|
|
}
|
|
|
|
|
2014-08-26 08:48:07 -07:00
|
|
|
void
|
2016-08-10 07:23:04 -07:00
|
|
|
_impl_ecore_exe_efl_object_destructor(Eo *obj, Ecore_Exe_Data *exe)
|
2009-10-16 02:17:26 -07:00
|
|
|
{
|
|
|
|
void *data;
|
|
|
|
|
2015-09-27 01:25:33 -07:00
|
|
|
_ecore_exe_threads_terminate(obj);
|
|
|
|
|
2009-10-16 02:17:26 -07:00
|
|
|
data = exe->data;
|
2010-01-05 22:56:23 -08:00
|
|
|
if (exe->pre_free_cb)
|
2014-08-26 08:48:07 -07:00
|
|
|
exe->pre_free_cb(data, obj);
|
2010-01-05 22:56:23 -08:00
|
|
|
|
2015-09-27 02:24:42 -07:00
|
|
|
IF_FN_DEL(ecore_main_win32_handler_del, exe->h_close);
|
2015-07-07 03:36:06 -07:00
|
|
|
|
2015-09-27 02:24:42 -07:00
|
|
|
IF_FN_DEL(CloseHandle, exe->process_thread);
|
|
|
|
IF_FN_DEL(CloseHandle, exe->process);
|
|
|
|
IF_FN_DEL(CloseHandle, exe->pipe_write.child_pipe);
|
|
|
|
IF_FN_DEL(CloseHandle, exe->pipe_write.child_pipe_x);
|
|
|
|
IF_FN_DEL(CloseHandle, exe->pipe_error.child_pipe);
|
|
|
|
IF_FN_DEL(CloseHandle, exe->pipe_read.child_pipe);
|
2015-07-07 03:36:06 -07:00
|
|
|
|
2015-09-27 02:24:42 -07:00
|
|
|
IF_FREE(exe->cmd);
|
2014-04-25 03:23:41 -07:00
|
|
|
|
2014-08-27 03:00:11 -07:00
|
|
|
_ecore_exe_exes = eina_list_remove(_ecore_exe_exes, obj);
|
2014-04-25 03:23:41 -07:00
|
|
|
IF_FREE(exe->tag);
|
2009-10-16 02:17:26 -07:00
|
|
|
}
|
|
|
|
|
2014-08-26 08:48:07 -07:00
|
|
|
void
|
2014-08-27 03:00:11 -07:00
|
|
|
_impl_ecore_exe_pause(Ecore_Exe *obj EINA_UNUSED, Ecore_Exe_Data *exe)
|
2009-10-16 02:17:26 -07:00
|
|
|
{
|
|
|
|
if (exe->is_suspended)
|
|
|
|
return;
|
|
|
|
|
2010-05-15 11:38:01 -07:00
|
|
|
if (SuspendThread(exe->process_thread) != (DWORD)-1)
|
2009-10-16 02:17:26 -07:00
|
|
|
exe->is_suspended = 1;
|
|
|
|
}
|
|
|
|
|
2014-08-26 08:48:07 -07:00
|
|
|
void
|
2014-08-27 03:00:11 -07:00
|
|
|
_impl_ecore_exe_continue(Ecore_Exe *obj EINA_UNUSED, Ecore_Exe_Data *exe)
|
2009-10-16 02:17:26 -07:00
|
|
|
{
|
|
|
|
if (!exe->is_suspended)
|
|
|
|
return;
|
|
|
|
|
2010-05-15 11:38:01 -07:00
|
|
|
if (ResumeThread(exe->process_thread) != (DWORD)-1)
|
2009-10-16 02:17:26 -07:00
|
|
|
exe->is_suspended = 0;
|
|
|
|
}
|
|
|
|
|
2014-08-26 08:48:07 -07:00
|
|
|
void
|
2014-08-27 03:00:11 -07:00
|
|
|
_impl_ecore_exe_interrupt(Ecore_Exe *obj, Ecore_Exe_Data *exe)
|
2009-10-16 02:17:26 -07:00
|
|
|
{
|
2010-05-15 11:38:01 -07:00
|
|
|
CloseHandle(exe->process_thread);
|
2014-04-25 03:23:41 -07:00
|
|
|
exe->process_thread = NULL;
|
2009-10-16 02:17:26 -07:00
|
|
|
CloseHandle(exe->process);
|
2014-04-25 03:23:41 -07:00
|
|
|
exe->process = NULL;
|
2009-10-16 02:17:26 -07:00
|
|
|
exe->sig = ECORE_EXE_WIN32_SIGINT;
|
2015-09-27 03:15:04 -07:00
|
|
|
EnumWindows(_ecore_exe_enum_windows_procedure, (LPARAM)obj);
|
2009-10-16 02:17:26 -07:00
|
|
|
}
|
|
|
|
|
2014-08-26 08:48:07 -07:00
|
|
|
void
|
2014-08-27 03:00:11 -07:00
|
|
|
_impl_ecore_exe_quit(Ecore_Exe *obj, Ecore_Exe_Data *exe)
|
2009-10-16 02:17:26 -07:00
|
|
|
{
|
2010-05-15 11:38:01 -07:00
|
|
|
CloseHandle(exe->process_thread);
|
2014-04-25 03:23:41 -07:00
|
|
|
exe->process_thread = NULL;
|
2009-10-16 02:17:26 -07:00
|
|
|
CloseHandle(exe->process);
|
2014-04-25 03:23:41 -07:00
|
|
|
exe->process = NULL;
|
2009-10-16 02:17:26 -07:00
|
|
|
exe->sig = ECORE_EXE_WIN32_SIGQUIT;
|
2015-09-27 03:15:04 -07:00
|
|
|
EnumWindows(_ecore_exe_enum_windows_procedure, (LPARAM)obj);
|
2009-10-16 02:17:26 -07:00
|
|
|
}
|
|
|
|
|
2014-08-26 08:48:07 -07:00
|
|
|
void
|
2014-08-27 03:00:11 -07:00
|
|
|
_impl_ecore_exe_terminate(Ecore_Exe *obj, Ecore_Exe_Data *exe)
|
2009-10-16 02:17:26 -07:00
|
|
|
{
|
2009-11-08 14:19:30 -08:00
|
|
|
/* CloseHandle(exe->thread); */
|
2009-10-16 02:17:26 -07:00
|
|
|
CloseHandle(exe->process);
|
2014-04-25 03:23:41 -07:00
|
|
|
exe->process = NULL;
|
2009-10-16 02:17:26 -07:00
|
|
|
exe->sig = ECORE_EXE_WIN32_SIGTERM;
|
2014-08-26 07:15:50 -07:00
|
|
|
while (EnumWindows(_ecore_exe_enum_windows_procedure, (LPARAM)obj)) ;
|
2009-10-16 02:17:26 -07:00
|
|
|
}
|
|
|
|
|
2014-08-26 08:48:07 -07:00
|
|
|
void
|
2014-08-27 03:00:11 -07:00
|
|
|
_impl_ecore_exe_kill(Ecore_Exe *obj, Ecore_Exe_Data *exe)
|
2009-10-16 02:17:26 -07:00
|
|
|
{
|
2010-05-15 11:38:01 -07:00
|
|
|
CloseHandle(exe->process_thread);
|
2014-04-25 03:23:41 -07:00
|
|
|
exe->process_thread = NULL;
|
2009-10-16 02:17:26 -07:00
|
|
|
CloseHandle(exe->process);
|
2014-04-25 03:23:41 -07:00
|
|
|
exe->process = NULL;
|
2009-10-16 02:17:26 -07:00
|
|
|
exe->sig = ECORE_EXE_WIN32_SIGKILL;
|
2014-08-26 07:15:50 -07:00
|
|
|
while (EnumWindows(_ecore_exe_enum_windows_procedure, (LPARAM)obj)) ;
|
2009-10-16 02:17:26 -07:00
|
|
|
}
|
2014-08-27 03:00:11 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
_impl_ecore_exe_auto_limits_set(Ecore_Exe *obj EINA_UNUSED,
|
|
|
|
Ecore_Exe_Data *exe EINA_UNUSED,
|
|
|
|
int start_bytes EINA_UNUSED,
|
|
|
|
int end_bytes EINA_UNUSED,
|
|
|
|
int start_lines EINA_UNUSED,
|
|
|
|
int end_lines EINA_UNUSED)
|
|
|
|
{
|
|
|
|
ERR("Not implemented on windows!");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_impl_ecore_exe_signal(Ecore_Exe *obj EINA_UNUSED,
|
|
|
|
Ecore_Exe_Data *exe EINA_UNUSED,
|
|
|
|
int num EINA_UNUSED)
|
|
|
|
{
|
|
|
|
ERR("Not implemented on windows!");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_impl_ecore_exe_hup(Ecore_Exe *obj EINA_UNUSED,
|
|
|
|
Ecore_Exe_Data *exe EINA_UNUSED)
|
|
|
|
{
|
|
|
|
ERR("Not implemented on windows!");
|
|
|
|
}
|