attempt to fix windows usage of new python based proxies
This commit is contained in:
parent
52fcfecf24
commit
04825115b4
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Copyright (c) 2008, Arvid Norberg
|
Copyright (c) 2008, Arvid Norberg
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
@ -284,6 +284,10 @@ void test_sleep(int millisec)
|
||||||
libtorrent::sleep(millisec);
|
libtorrent::sleep(millisec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
typedef DWORD pid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct proxy_t
|
struct proxy_t
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
@ -360,7 +364,13 @@ void stop_all_proxies()
|
||||||
, end(proxies.end()); i != end; ++i)
|
, end(proxies.end()); i != end; ++i)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
HANDLE proc = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE, FALSE, i->second.pid);
|
||||||
GenerateConsoleCtrlEvent(CTRL_C_EVENT, i->second.pid);
|
GenerateConsoleCtrlEvent(CTRL_C_EVENT, i->second.pid);
|
||||||
|
int ret = WaitForSingleObject(proc, 1000);
|
||||||
|
// if the process didn't terminate in 1 second, kill it
|
||||||
|
if (ret != WAIT_OBJECT_0)
|
||||||
|
TerminateProcess(proc, 138);
|
||||||
|
CloseHandle(proc);
|
||||||
#else
|
#else
|
||||||
printf("killing pid: %d\n", i->second.pid);
|
printf("killing pid: %d\n", i->second.pid);
|
||||||
kill(i->second.pid, SIGINT);
|
kill(i->second.pid, SIGINT);
|
||||||
|
|
Loading…
Reference in New Issue