diff options
Diffstat (limited to 'src/w32proc.c')
| -rw-r--r-- | src/w32proc.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/w32proc.c b/src/w32proc.c index 961791a40ed..84589388cd7 100644 --- a/src/w32proc.c +++ b/src/w32proc.c | |||
| @@ -2263,12 +2263,42 @@ sys_kill (pid_t pid, int sig) | |||
| 2263 | pid = -pid; | 2263 | pid = -pid; |
| 2264 | 2264 | ||
| 2265 | /* Only handle signals that will result in the process dying */ | 2265 | /* Only handle signals that will result in the process dying */ |
| 2266 | if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP) | 2266 | if (sig != 0 |
| 2267 | && sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP) | ||
| 2267 | { | 2268 | { |
| 2268 | errno = EINVAL; | 2269 | errno = EINVAL; |
| 2269 | return -1; | 2270 | return -1; |
| 2270 | } | 2271 | } |
| 2271 | 2272 | ||
| 2273 | if (sig == 0) | ||
| 2274 | { | ||
| 2275 | /* It will take _some_ time before PID 4 or less on Windows will | ||
| 2276 | be Emacs... */ | ||
| 2277 | if (pid <= 4) | ||
| 2278 | { | ||
| 2279 | errno = EPERM; | ||
| 2280 | return -1; | ||
| 2281 | } | ||
| 2282 | proc_hand = OpenProcess (PROCESS_QUERY_INFORMATION, 0, pid); | ||
| 2283 | if (proc_hand == NULL) | ||
| 2284 | { | ||
| 2285 | DWORD err = GetLastError (); | ||
| 2286 | |||
| 2287 | switch (err) | ||
| 2288 | { | ||
| 2289 | case ERROR_ACCESS_DENIED: /* existing process, but access denied */ | ||
| 2290 | errno = EPERM; | ||
| 2291 | return -1; | ||
| 2292 | case ERROR_INVALID_PARAMETER: /* process PID does not exist */ | ||
| 2293 | errno = ESRCH; | ||
| 2294 | return -1; | ||
| 2295 | } | ||
| 2296 | } | ||
| 2297 | else | ||
| 2298 | CloseHandle (proc_hand); | ||
| 2299 | return 0; | ||
| 2300 | } | ||
| 2301 | |||
| 2272 | cp = find_child_pid (pid); | 2302 | cp = find_child_pid (pid); |
| 2273 | if (cp == NULL) | 2303 | if (cp == NULL) |
| 2274 | { | 2304 | { |