fixes for compatibility

Conflicts:
	Foundation/src/Process_WIN32.cpp
	Foundation/src/Process_WIN32U.cpp
This commit is contained in:
Günter Obiltschnig 2016-04-15 17:40:09 +02:00 committed by Guenter Obiltschnig
parent 6d17089b6c
commit 913346c23d
3 changed files with 76 additions and 80 deletions

View File

@ -27,7 +27,7 @@ namespace Poco {
//
// ProcessHandleImpl
//
ProcessHandleImpl::ProcessHandleImpl(HANDLE hProcess, UInt32 pid):
ProcessHandleImpl::ProcessHandleImpl(HANDLE hProcess, UInt32 pid) :
_hProcess(hProcess),
_pid(pid)
{
@ -95,10 +95,10 @@ void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
ULARGE_INTEGER time;
time.LowPart = ftKernel.dwLowDateTime;
time.HighPart = ftKernel.dwHighDateTime;
kernelTime = long(time.QuadPart/10000000L);
kernelTime = long(time.QuadPart / 10000000L);
time.LowPart = ftUser.dwLowDateTime;
time.HighPart = ftUser.dwHighDateTime;
userTime = long(time.QuadPart/10000000L);
userTime = long(time.QuadPart / 10000000L);
}
else
{
@ -109,7 +109,7 @@ void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
static bool argNeedsEscaping(const std::string& arg)
{
bool containsQuotableChar = arg.npos != arg.find_first_of(" \t\n\v\"");
bool containsQuotableChar = std::string::npos != arg.find_first_of(" \t\n\v\"");
// Assume args that start and end with quotes are already quoted and do not require further quoting.
// There is probably code out there written before launch() escaped the arguments that does its own
// escaping of arguments. This ensures we do not interfere with those arguments.
@ -124,7 +124,7 @@ static std::string escapeArg(const std::string& arg)
if (argNeedsEscaping(arg))
{
std::string quotedArg("\"");
for (auto it = arg.begin(); ; ++it)
for (std::string::const_iterator it = arg.begin(); ; ++it)
{
unsigned backslashCount = 0;
while (it != arg.end() && '\\' == *it)
@ -251,7 +251,7 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
NULL, // threadAttributes
mustInheritHandles,
creationFlags,
(LPVOID) pEnv,
(LPVOID)pEnv,
workingDirectory,
&startupInfo,
&processInfo
@ -301,6 +301,8 @@ void ProcessImpl::killImpl(PIDImpl pid)
throw NoPermissionException("cannot kill process");
case ERROR_NOT_FOUND:
throw NotFoundException("cannot kill process");
case ERROR_INVALID_PARAMETER:
throw NotFoundException("cannot kill process");
default:
throw SystemException("cannot kill process");
}

View File

@ -28,7 +28,7 @@ namespace Poco {
//
// ProcessHandleImpl
//
ProcessHandleImpl::ProcessHandleImpl(HANDLE hProcess, UInt32 pid):
ProcessHandleImpl::ProcessHandleImpl(HANDLE hProcess, UInt32 pid) :
_hProcess(hProcess),
_pid(pid)
{
@ -96,10 +96,10 @@ void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
ULARGE_INTEGER time;
time.LowPart = ftKernel.dwLowDateTime;
time.HighPart = ftKernel.dwHighDateTime;
kernelTime = long(time.QuadPart/10000000L);
kernelTime = long(time.QuadPart / 10000000L);
time.LowPart = ftUser.dwLowDateTime;
time.HighPart = ftUser.dwHighDateTime;
userTime = long(time.QuadPart/10000000L);
userTime = long(time.QuadPart / 10000000L);
}
else
{
@ -110,7 +110,7 @@ void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
static bool argNeedsEscaping(const std::string& arg)
{
bool containsQuotableChar = arg.npos != arg.find_first_of(" \t\n\v\"");
bool containsQuotableChar = std::string::npos != arg.find_first_of(" \t\n\v\"");
// Assume args that start and end with quotes are already quoted and do not require further quoting.
// There is probably code out there written before launch() escaped the arguments that does its own
// escaping of arguments. This ensures we do not interfere with those arguments.
@ -125,7 +125,7 @@ static std::string escapeArg(const std::string& arg)
if (argNeedsEscaping(arg))
{
std::string quotedArg("\"");
for (auto it = arg.begin(); ; ++it)
for (std::string::const_iterator it = arg.begin(); ; ++it)
{
unsigned backslashCount = 0;
while (it != arg.end() && '\\' == *it)
@ -257,7 +257,7 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
NULL, // threadAttributes
mustInheritHandles,
creationFlags,
(LPVOID) pEnv,
(LPVOID)pEnv,
workingDirectory,
&startupInfo,
&processInfo
@ -298,8 +298,7 @@ void ProcessImpl::killImpl(PIDImpl pid)
throw SystemException("cannot kill process");
}
CloseHandle(hProc);
}
else
} else
{
switch (GetLastError())
{
@ -307,6 +306,8 @@ void ProcessImpl::killImpl(PIDImpl pid)
throw NoPermissionException("cannot kill process");
case ERROR_NOT_FOUND:
throw NotFoundException("cannot kill process");
case ERROR_INVALID_PARAMETER:
throw NotFoundException("cannot kill process");
default:
throw SystemException("cannot kill process");
}

View File

@ -159,16 +159,9 @@ void ProcessTest::testLaunchEnv()
void ProcessTest::testLaunchArgs()
{
#if !defined(_WIN32_WCE)
#if defined (_WIN32) && !defined(_WIN32_WCE)
std::string name("TestApp");
std::string cmd;
#if defined(POCO_OS_FAMILY_UNIX)
cmd = "./";
cmd += name;
#else
cmd = name;
#endif
std::string cmd = name;
std::vector<std::string> args;
args.push_back("-echo-args");