[Box Backup-commit] COMMIT r2224 - box/trunk/lib/server
boxbackup-dev at fluffy.co.uk
boxbackup-dev at fluffy.co.uk
Thu Aug 7 17:31:33 BST 2008
Author: chris
Date: 2008-08-07 17:31:32 +0100 (Thu, 07 Aug 2008)
New Revision: 2224
Modified:
box/trunk/lib/server/ServerControl.cpp
box/trunk/lib/server/ServerControl.h
Log:
Allow waiting for a process while killing it, will be needed for tests
that fork() to avoid zombies and for ServerIsAlive to work.
Modified: box/trunk/lib/server/ServerControl.cpp
===================================================================
--- box/trunk/lib/server/ServerControl.cpp 2008-08-07 16:30:40 UTC (rev 2223)
+++ box/trunk/lib/server/ServerControl.cpp 2008-08-07 16:31:32 UTC (rev 2224)
@@ -6,6 +6,10 @@
#include <sys/types.h>
#endif
+#ifdef HAVE_SYS_WAIT_H
+ #include <sys/wait.h>
+#endif
+
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
@@ -160,18 +164,43 @@
#endif // WIN32
-bool KillServer(int pid)
+bool KillServer(int pid, bool WaitForProcess)
{
if (!KillServerInternal(pid))
{
return false;
}
+ #ifdef HAVE_WAITPID
+ if (WaitForProcess)
+ {
+ int status, result;
+
+ result = waitpid(pid, &status, 0);
+ if (result != pid)
+ {
+ BOX_WARNING("waitpid returned " << result);
+ }
+ TEST_THAT(result == pid);
+
+ TEST_THAT(WIFEXITED(status));
+ if (WIFEXITED(status))
+ {
+ if (WEXITSTATUS(status) != 0)
+ {
+ BOX_WARNING("process exited with code " <<
+ WEXITSTATUS(status));
+ }
+ TEST_THAT(WEXITSTATUS(status) == 0);
+ }
+ }
+ #endif
+
for (int i = 0; i < 30; i++)
{
if (i == 0)
{
- printf("Waiting for server to die: ");
+ printf("Waiting for server to die (pid %d): ", pid);
}
printf(".");
Modified: box/trunk/lib/server/ServerControl.h
===================================================================
--- box/trunk/lib/server/ServerControl.h 2008-08-07 16:30:40 UTC (rev 2223)
+++ box/trunk/lib/server/ServerControl.h 2008-08-07 16:31:32 UTC (rev 2224)
@@ -4,7 +4,7 @@
#include "Test.h"
bool HUPServer(int pid);
-bool KillServer(int pid);
+bool KillServer(int pid, bool WaitForProcess = false);
#ifdef WIN32
#include "WinNamedPipeStream.h"
More information about the Boxbackup-commit
mailing list