* kill.cc (get_debug_priv): New function.
(forcekill): Call get_debug_priv before trying to kill process.
This commit is contained in:
parent
2e93c97146
commit
5817840adf
|
@ -1,3 +1,8 @@
|
|||
2004-03-13 Rob Siklos <rob2@siklos.ca>
|
||||
|
||||
* kill.cc (get_debug_priv): New function.
|
||||
(forcekill): Call get_debug_priv before trying to kill process.
|
||||
|
||||
2004-02-24 Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
* cygpath.cc (long_options): Add "mode" option.
|
||||
|
|
|
@ -125,9 +125,38 @@ listsig (const char *in_sig)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_debug_priv (void)
|
||||
{
|
||||
HANDLE tok;
|
||||
LUID luid;
|
||||
TOKEN_PRIVILEGES tkp;
|
||||
|
||||
if (!OpenProcessToken (GetCurrentProcess (),
|
||||
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &tok))
|
||||
return;
|
||||
|
||||
if (!LookupPrivilegeValue (NULL, SE_DEBUG_NAME, &luid))
|
||||
{
|
||||
CloseHandle (tok);
|
||||
return;
|
||||
}
|
||||
|
||||
tkp.PrivilegeCount = 1;
|
||||
tkp.Privileges[0].Luid = luid;
|
||||
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
AdjustTokenPrivileges (tok, FALSE, &tkp, sizeof tkp, NULL, NULL);
|
||||
|
||||
CloseHandle (tok);
|
||||
}
|
||||
|
||||
static void __stdcall
|
||||
forcekill (int pid, int sig, int wait)
|
||||
{
|
||||
// try to acquire SeDebugPrivilege
|
||||
get_debug_priv();
|
||||
|
||||
external_pinfo *p = (external_pinfo *) cygwin_internal (CW_GETPINFO_FULL, pid);
|
||||
DWORD dwpid = p ? p->dwProcessId : (DWORD) pid;
|
||||
HANDLE h = OpenProcess (PROCESS_TERMINATE, FALSE, (DWORD) dwpid);
|
||||
|
@ -254,3 +283,4 @@ out:
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue