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:
>Hello,
>
>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 kill.cc 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),
>
>http://msdn.microsoft.com/en-us/library/windows/desktop/ms684320%28v=vs.85%29.aspx
>
><quote>
>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.
></quote>
>
>http://msdn.microsoft.com/en-us/library/windows/desktop/ms684880%28v=vs.85%29.aspx

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.

cgf

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


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