summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2015-09-27 13:27:15 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-10-12 17:21:59 -0700
commit188508641307fb2a17c6782af91eb8b979f5130a (patch)
tree7c50b928965dd900d45ec66103cc111e01f09c6e /src/lib
parentb8a968475529acac2e1fc5db5cb460a82659c127 (diff)
ecore_exe: fix command line when a shell is used, and increase buffer to 32768 bytes
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ecore/ecore_exe_win32.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/lib/ecore/ecore_exe_win32.c b/src/lib/ecore/ecore_exe_win32.c
index 7c8d90b338..73957d7d5d 100644
--- a/src/lib/ecore/ecore_exe_win32.c
+++ b/src/lib/ecore/ecore_exe_win32.c
@@ -378,23 +378,24 @@ _impl_ecore_exe_run_priority_get(void)
378Eo * 378Eo *
379_impl_ecore_exe_eo_base_finalize(Eo *obj, Ecore_Exe_Data *exe) 379_impl_ecore_exe_eo_base_finalize(Eo *obj, Ecore_Exe_Data *exe)
380{ 380{
381 char exe_cmd_buf[1024]; 381 char exe_cmd_buf[32768];
382 SECURITY_ATTRIBUTES sa; 382 SECURITY_ATTRIBUTES sa;
383 STARTUPINFO si; 383 STARTUPINFO si;
384 PROCESS_INFORMATION pi;
384 HANDLE child_pipe_read; 385 HANDLE child_pipe_read;
385 HANDLE child_pipe_error; 386 HANDLE child_pipe_error;
386 PROCESS_INFORMATION pi; 387 const char *shell = NULL;
387 Ecore_Exe_Event_Add *e; 388 Ecore_Exe_Event_Add *e;
389 Ecore_Exe_Flags flags;
388 Eina_Bool use_sh = EINA_FALSE; 390 Eina_Bool use_sh = EINA_FALSE;
389 const char *shell = NULL;
390 391
391 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL); 392 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
392 393
393 const char *exe_cmd = exe->cmd; 394 flags = exe->flags;
394 DBG("Creating process %s", exe_cmd);
395 Ecore_Exe_Flags flags = exe->flags;
396 395
397 if (!exe_cmd) goto error; 396 DBG("Creating process %s", exe->cmd);
397
398 if (!exe->cmd) goto error;
398 399
399 if ((flags & ECORE_EXE_PIPE_AUTO) && (!(flags & ECORE_EXE_PIPE_ERROR)) 400 if ((flags & ECORE_EXE_PIPE_AUTO) && (!(flags & ECORE_EXE_PIPE_ERROR))
400 && (!(flags & ECORE_EXE_PIPE_READ))) 401 && (!(flags & ECORE_EXE_PIPE_READ)))
@@ -404,20 +405,14 @@ _impl_ecore_exe_eo_base_finalize(Eo *obj, Ecore_Exe_Data *exe)
404 if ((flags & ECORE_EXE_USE_SH)) 405 if ((flags & ECORE_EXE_USE_SH))
405 use_sh = EINA_TRUE; 406 use_sh = EINA_TRUE;
406 else 407 else
407 { 408 use_sh = eina_str_has_extension(exe->cmd, ".bat");
408 char *ret;
409
410 ret = strrstr(exe_cmd, ".bat");
411 if (ret && (ret[4] == '\0'))
412 use_sh = EINA_TRUE;
413 }
414 409
415 if (use_sh) 410 if (use_sh)
416 { 411 {
417 int len; 412 int len;
418 413
419 shell = "cmd.exe"; 414 shell = "cmd.exe";
420 len = snprintf(exe_cmd_buf, sizeof(exe_cmd_buf), "/c %s", exe_cmd); 415 len = snprintf(exe_cmd_buf, sizeof(exe_cmd_buf), "/c %s", exe->cmd);
421 if (len >= (int)sizeof(exe_cmd_buf)) 416 if (len >= (int)sizeof(exe_cmd_buf))
422 exe_cmd_buf[sizeof(exe_cmd_buf) - 1] = '\0'; 417 exe_cmd_buf[sizeof(exe_cmd_buf) - 1] = '\0';
423 } 418 }
@@ -426,7 +421,7 @@ _impl_ecore_exe_eo_base_finalize(Eo *obj, Ecore_Exe_Data *exe)
426 int len; 421 int len;
427 422
428 /* FIXME : faster with memset() but one must be careful with size */ 423 /* FIXME : faster with memset() but one must be careful with size */
429 len = snprintf(exe_cmd_buf, sizeof(exe_cmd_buf), "%s", exe_cmd); 424 len = snprintf(exe_cmd_buf, sizeof(exe_cmd_buf), "%s", exe->cmd);
430 if (len >= (int)sizeof(exe_cmd_buf)) 425 if (len >= (int)sizeof(exe_cmd_buf))
431 exe_cmd_buf[sizeof(exe_cmd_buf) - 1] = '\0'; 426 exe_cmd_buf[sizeof(exe_cmd_buf) - 1] = '\0';
432 } 427 }
@@ -485,8 +480,8 @@ _impl_ecore_exe_eo_base_finalize(Eo *obj, Ecore_Exe_Data *exe)
485 si.hStdError = child_pipe_error; 480 si.hStdError = child_pipe_error;
486 si.dwFlags |= STARTF_USESTDHANDLES; 481 si.dwFlags |= STARTF_USESTDHANDLES;
487 482
488 DBG("CreateProcess: shell:%s child:%s", use_sh ? "yes" : "no", exe->cmd); 483 DBG("CreateProcess: shell:%s child:%s", use_sh ? "yes" : "no", exe_cmd_buf);
489 if (!CreateProcess(shell, exe->cmd, NULL, NULL, EINA_TRUE, 484 if (!CreateProcess(shell, exe_cmd_buf, NULL, NULL, EINA_TRUE,
490 run_pri | CREATE_SUSPENDED, NULL, NULL, &si, &pi)) 485 run_pri | CREATE_SUSPENDED, NULL, NULL, &si, &pi))
491 { 486 {
492 char *msg; 487 char *msg;
@@ -494,11 +489,11 @@ _impl_ecore_exe_eo_base_finalize(Eo *obj, Ecore_Exe_Data *exe)
494 msg = evil_last_error_get(); 489 msg = evil_last_error_get();
495 if (msg) 490 if (msg)
496 { 491 {
497 WRN("Failed to create process %s: %s", exe->cmd, msg); 492 WRN("Failed to create process %s: %s", exe_cmd_buf, msg);
498 free(msg); 493 free(msg);
499 } 494 }
500 else 495 else
501 WRN("Failed to create process %s: %ld", exe->cmd, GetLastError()); 496 WRN("Failed to create process %s: %ld", exe_cmd_buf, GetLastError());
502 goto error; 497 goto error;
503 } 498 }
504 499