mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-20 04:35:34 +01:00
Merge branch 'develop' of https://github.com/pocoproject/poco into develop
This commit is contained in:
commit
5e29ae31c1
@ -18,6 +18,7 @@
|
|||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include "Poco/NumberFormatter.h"
|
#include "Poco/NumberFormatter.h"
|
||||||
#include "Poco/Pipe.h"
|
#include "Poco/Pipe.h"
|
||||||
|
#include <limits>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -68,7 +69,12 @@ int ProcessHandleImpl::wait() const
|
|||||||
while (rc < 0 && errno == EINTR);
|
while (rc < 0 && errno == EINTR);
|
||||||
if (rc != _pid)
|
if (rc != _pid)
|
||||||
throw SystemException("Cannot wait for process", NumberFormatter::format(_pid));
|
throw SystemException("Cannot wait for process", NumberFormatter::format(_pid));
|
||||||
return WEXITSTATUS(status);
|
if (WIFEXITED(status))
|
||||||
|
return WEXITSTATUS(status);
|
||||||
|
if (WIFSIGNALED(status))
|
||||||
|
return -WTERMSIG(status);
|
||||||
|
// This line should never be reached.
|
||||||
|
return std::numeric_limits<int>::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "Poco/Process.h"
|
#include "Poco/Process.h"
|
||||||
#include "Poco/Pipe.h"
|
#include "Poco/Pipe.h"
|
||||||
#include "Poco/PipeStream.h"
|
#include "Poco/PipeStream.h"
|
||||||
|
#include <csignal>
|
||||||
|
|
||||||
|
|
||||||
using Poco::Process;
|
using Poco::Process;
|
||||||
@ -190,6 +191,27 @@ void ProcessTest::testIsRunning()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProcessTest::testSignalExitCode()
|
||||||
|
{
|
||||||
|
#if defined(POCO_OS_FAMILY_UNIX)
|
||||||
|
std::string name("TestApp");
|
||||||
|
std::string cmd;
|
||||||
|
#if defined(_DEBUG)
|
||||||
|
name += "d";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cmd = "./";
|
||||||
|
cmd += name;
|
||||||
|
|
||||||
|
std::vector<std::string> args;
|
||||||
|
args.push_back("-raise-int");
|
||||||
|
ProcessHandle ph = Process::launch(cmd, args, 0, 0, 0);
|
||||||
|
int rc = ph.wait();
|
||||||
|
assert (rc == -SIGINT);
|
||||||
|
#endif // defined(POCO_OS_FAMILY_UNIX)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ProcessTest::setUp()
|
void ProcessTest::setUp()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -209,6 +231,7 @@ CppUnit::Test* ProcessTest::suite()
|
|||||||
CppUnit_addTest(pSuite, ProcessTest, testLaunchRedirectOut);
|
CppUnit_addTest(pSuite, ProcessTest, testLaunchRedirectOut);
|
||||||
CppUnit_addTest(pSuite, ProcessTest, testLaunchEnv);
|
CppUnit_addTest(pSuite, ProcessTest, testLaunchEnv);
|
||||||
CppUnit_addTest(pSuite, ProcessTest, testIsRunning);
|
CppUnit_addTest(pSuite, ProcessTest, testIsRunning);
|
||||||
|
CppUnit_addTest(pSuite, ProcessTest, testSignalExitCode);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ public:
|
|||||||
void testLaunchRedirectOut();
|
void testLaunchRedirectOut();
|
||||||
void testLaunchEnv();
|
void testLaunchEnv();
|
||||||
void testIsRunning();
|
void testIsRunning();
|
||||||
|
void testSignalExitCode();
|
||||||
|
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <csignal>
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
@ -46,6 +47,10 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
else return 1;
|
else return 1;
|
||||||
}
|
}
|
||||||
|
else if (arg == "-raise-int")
|
||||||
|
{
|
||||||
|
std::raise(SIGINT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return argc - 1;
|
return argc - 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user