diff options
| author | Eli Zaretskii | 2008-08-09 19:05:54 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2008-08-09 19:05:54 +0000 |
| commit | 754a2d1380c19e854549b84af6f96e94aef0d77f (patch) | |
| tree | 1b8ab80819b586bc4b56eaa94deaf5b5a5de016f /src | |
| parent | 3af03101a78a582ce3b788b56009323a95638b83 (diff) | |
| download | emacs-754a2d1380c19e854549b84af6f96e94aef0d77f.tar.gz emacs-754a2d1380c19e854549b84af6f96e94aef0d77f.zip | |
(w32_system_process_attributes): If the process does not exist, return nil.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 3 | ||||
| -rw-r--r-- | src/w32.c | 8 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 7fdffb7df38..37a405efb5c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2008-08-09 Eli Zaretskii <eliz@gnu.org> | 1 | 2008-08-09 Eli Zaretskii <eliz@gnu.org> |
| 2 | 2 | ||
| 3 | * w32.c (w32_system_process_attributes): If the process does not | ||
| 4 | exist, return nil. | ||
| 5 | |||
| 3 | * w32.c: Include thelp32.h, psapi.h and coding.h. | 6 | * w32.c: Include thelp32.h, psapi.h and coding.h. |
| 4 | (_MEMORYSTATUSEX, _PROCESS_MEMORY_COUNTERS_EX): New struct | 7 | (_MEMORYSTATUSEX, _PROCESS_MEMORY_COUNTERS_EX): New struct |
| 5 | declarations. | 8 | declarations. |
| @@ -3642,6 +3642,7 @@ w32_system_process_attributes (pid) | |||
| 3642 | Lisp_Object cmd_str, decoded_cmd, tem; | 3642 | Lisp_Object cmd_str, decoded_cmd, tem; |
| 3643 | HANDLE h_snapshot, h_proc; | 3643 | HANDLE h_snapshot, h_proc; |
| 3644 | DWORD proc_id; | 3644 | DWORD proc_id; |
| 3645 | int found_proc = 0; | ||
| 3645 | char uname[UNLEN+1], gname[GNLEN+1], domain[1025]; | 3646 | char uname[UNLEN+1], gname[GNLEN+1], domain[1025]; |
| 3646 | DWORD ulength = sizeof (uname), dlength = sizeof (domain), trash; | 3647 | DWORD ulength = sizeof (uname), dlength = sizeof (domain), trash; |
| 3647 | DWORD glength = sizeof (gname); | 3648 | DWORD glength = sizeof (gname); |
| @@ -3701,6 +3702,7 @@ w32_system_process_attributes (pid) | |||
| 3701 | attrs = Fcons (Fcons (Qthcount, | 3702 | attrs = Fcons (Fcons (Qthcount, |
| 3702 | make_fixnum_or_float (pe.cntThreads)), | 3703 | make_fixnum_or_float (pe.cntThreads)), |
| 3703 | attrs); | 3704 | attrs); |
| 3705 | found_proc = 1; | ||
| 3704 | break; | 3706 | break; |
| 3705 | } | 3707 | } |
| 3706 | } | 3708 | } |
| @@ -3708,6 +3710,12 @@ w32_system_process_attributes (pid) | |||
| 3708 | CloseHandle (h_snapshot); | 3710 | CloseHandle (h_snapshot); |
| 3709 | } | 3711 | } |
| 3710 | 3712 | ||
| 3713 | if (!found_proc) | ||
| 3714 | { | ||
| 3715 | UNGCPRO; | ||
| 3716 | return Qnil; | ||
| 3717 | } | ||
| 3718 | |||
| 3711 | h_proc = OpenProcess (PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, | 3719 | h_proc = OpenProcess (PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, |
| 3712 | FALSE, proc_id); | 3720 | FALSE, proc_id); |
| 3713 | /* If we were denied a handle to the process, try again after | 3721 | /* If we were denied a handle to the process, try again after |