calling wxExecute() from a CL plugin returns -1 ("failed to execute") instead of 0, with wx logging "Debug: In file ../src/unix/utilsunx.cpp at line 1502: waitpid(16177)' failed with error 0x0000000a (No child processes)."
Ignoring the return code and accessing wxProcess::GetInputStream() does work so it seems it's just a bad error code. Variants like wxExecute(cmd, wxArrayString &output) don't work because wxDoExecuteWithCapture() (in wx/src/common/utilscmn.cpp) doesn't write to output if rc == -1.
I logged a few CL functions (see below) and ChildTerminatedSingalHandler() is called on all processes, even those not created by IProcess. The test code that produced the logs is attached.
I couldn't figure out a fix, assuming this actually is a bug. Maybe you can determine if a pid belongs to an IProcess (with a hashset or else) and if not let it pass through your signal handler or add a wrapper around IPlugin functions to shield processes it spawns... or something simpler.
thx & cheers,
-- p
platform: CL trunk, Debian/Gtk Wheezy x64, tested with wx294 & wx Trunk
Log when called from a CL plugin:
Code: Select all
UnixProcessImpl::Terminate(pid 5246)
IProcess::SetProcessExitCode(pid 5246, exitcode 0)
ChildTerminatedSingalHandler signo(17), pid(5246), status(15)
IProcess::SetProcessExitCode(pid 5249, exitcode 0)
ChildTerminatedSingalHandler signo(17), pid(5249), status(0)
IProcess::SetProcessExitCode(pid 5251, exitcode 0)
ChildTerminatedSingalHandler signo(17), pid(5251), status(0)
LocateApp("gprof")
IProcess::SetProcessExitCode(pid 5261, exitcode 0)
ChildTerminatedSingalHandler signo(17), pid(5261), status(0)
22:41:57: Debug: In file ../src/unix/utilsunx.cpp at line 1502: 'waitpid(5261)' failed with error 0x0000000a (No child processes).
wxExecute("which gprof") returned err -1, got 0 lines
LocateApp() returned "<ERROR>"
TestProcess("gprof")
IProcess::SetProcessExitCode(pid 5264, exitcode 0)
ChildTerminatedSingalHandler signo(17), pid(5264), status(0)
22:41:57: Debug: In file ../src/unix/utilsunx.cpp at line 1502: 'waitpid(5264)' failed with error 0x0000000a (No child processes).
wxExecute("which gprof") returned err -1, had pid 5264
returned "/usr/bin/gprof"
TestProcess() returned "/usr/bin/gprof"
CallGraph::GetGprofPath() : "/usr/bin/gprof"
CallGraph::CallGraph() initialized
Code: Select all
2013-04-06 23:07:28 : TestProcess("gprof")
2013-04-06 23:07:28 : wxExecute("which gprof") returned err 0, had pid 7169
2013-04-06 23:07:28 : returned "/usr/bin/gprof"
2013-04-06 23:07:28 : TestProcess() returned "/usr/bin/gprof"
2013-04-06 23:07:28 : LocateApp("gprof")
2013-04-06 23:07:28 : wxExecute("which gprof") returned err 0, got 1 lines
2013-04-06 23:07:28 : returned "/usr/bin/gprof"
2013-04-06 23:07:28 : LocateApp() returned "/usr/bin/gprof"