zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #03351
[Merge] lp:~zorba-coders/zorba/debugger_client_windows_termination into lp:zorba
Gabriel Petrovay has proposed merging lp:~zorba-coders/zorba/debugger_client_windows_termination into lp:zorba.
Requested reviews:
Gabriel Petrovay (gabipetrovay)
Juan Zacarias (juan457)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/debugger_client_windows_termination/+merge/87662
The process listener broke the Windows termination because of an invalid process handler that is not inherited in the listener thread.
This fixes this problem on Windows.
--
https://code.launchpad.net/~zorba-coders/zorba/debugger_client_windows_termination/+merge/87662
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'bin/debugger/main.cpp'
--- bin/debugger/main.cpp 2012-01-05 13:19:14 +0000
+++ bin/debugger/main.cpp 2012-01-05 17:33:13 +0000
@@ -143,7 +143,7 @@
if (lResult) {
// Watch the process
- ProcessListener* lPl = new ProcessListener(piProcessInfo.hProcess, &onExitProcess);
+ new ProcessListener(piProcessInfo.dwProcessId, &onExitProcess);
}
else {
// CreateProcess failed
=== modified file 'bin/debugger/process_listener.cpp'
--- bin/debugger/process_listener.cpp 2012-01-05 13:19:14 +0000
+++ bin/debugger/process_listener.cpp 2012-01-05 17:33:13 +0000
@@ -62,16 +62,20 @@
ProcessId lPid = lThis->getProcessID();
#ifdef WIN32
- // wait for the process to exit
- WaitForSingleObject(lPid, INFINITE);
-
- // find out the process exit code if possible
- if (!GetExitCodeProcess(lThis->getProcessID(), &lExitCode)) {
- lExitCode = -1;
+ HANDLE lProcessHandle = OpenProcess(SYNCHRONIZE, false, lPid);
+ if (lProcessHandle != NULL) {
+ // wait for the process to exit
+ DWORD lResult = WaitForSingleObject(lProcessHandle, INFINITE);
+
+ // find out the process exit code if possible
+ if (!GetExitCodeProcess(lProcessHandle, &lExitCode)) {
+ lExitCode = -1;
+ }
+ DWORD dw = GetLastError();
+
+ // wait a little for zorba to dump the garbage
+ Sleep(1000);
}
-
- // wait a little for zorba to dump the garbage
- Sleep(1000);
#else
int lChildExitStatus;
=== modified file 'bin/debugger/process_listener.h'
--- bin/debugger/process_listener.h 2012-01-05 13:19:14 +0000
+++ bin/debugger/process_listener.h 2012-01-05 17:33:13 +0000
@@ -29,7 +29,7 @@
#else
# include <windows.h>
typedef DWORD ThreadId;
- typedef HANDLE ProcessId;
+ typedef DWORD ProcessId;
typedef DWORD ExitCode;
# define ZORBA_THREAD_RETURN DWORD WINAPI
#endif
=== modified file 'src/debugger/debugger_communicator.cpp'
--- src/debugger/debugger_communicator.cpp 2011-12-21 14:40:33 +0000
+++ src/debugger/debugger_communicator.cpp 2012-01-05 17:33:13 +0000
@@ -74,10 +74,16 @@
}
}
+#ifdef NDEBUG
+# define TIMEOUT 6
+#else
+# define TIMEOUT 60
+#endif
+
void
DebuggerCommunicator::connect()
{
- for (int i = 0; i < 5 && !theSocket; i++)
+ for (int i = 0; i < TIMEOUT && !theSocket; i++)
{
try
{
@@ -94,7 +100,7 @@
catch (DebuggerSocketException& /* e */)
{
// Wait one second before trying to reconnect
- msleep(100);
+ msleep(1000);
}
}
}
Follow ups