This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cygwin kill utility //Was: cgwin_internal(): difference b/w CW_CYGWIN_PID_TO_WINPID and CW_GETPINFO_FULL for taking only dwProcessId ?

On Tue, Apr 08, 2014 at 03:01:18AM +0000, Lavrentiev, Anton (NIH/NLM/NCBI) [C] wrote:
>It looks like in order to effectively kill the process by Windows means (i.e. what Cygwin "kill -f" is supposed to do),
>the process handle must be obtained with the SYNCHRONIZE right (in addition to PROCESS_TERMINATE), otherwise
>WaitForSingleObject() fails with code 5, permission denied (at least for a regular user, i.e. not an administrator).
>That's about this portion of located at winsup\utils:
>  HANDLE h = OpenProcess (PROCESS_TERMINATE, FALSE, (DWORD) dwpid);
>  if (!h)
>    {
>      if (!wait || GetLastError () != ERROR_INVALID_PARAMETER)
>	fprintf (stderr, "%s: couldn't open pid %u\n",
>		 prog_name, (unsigned) dwpid);
>      return;
>    }
>  if (!wait || WaitForSingleObject (h, 200) != WAIT_OBJECT_0)
>    if (sig && !TerminateProcess (h, sig << 8)
>	&& WaitForSingleObject (h, 200) != WAIT_OBJECT_0)
>      fprintf (stderr, "%s: couldn't kill pid %u, %lu\n",
>	       prog_name, (unsigned) dwpid, GetLastError ());
>MSDN is in agreement with the observed behavior (access denied),
>The handle returned by the OpenProcess function can be used in any function that requires a handle to a process, such as the wait functions, provided the appropriate access rights were requested.

If only there was some way to programatically supply a change in source
code from party A which could be applied to the source code by party B,
along with a description which logs the change.  Nah.  Maybe we'll have
something when the Singularity finally occurs.


Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]