]> git.eshelyaron.com Git - emacs.git/commitdiff
(w32_system_process_attributes): If the process does not exist, return nil.
authorEli Zaretskii <eliz@gnu.org>
Sat, 9 Aug 2008 19:05:54 +0000 (19:05 +0000)
committerEli Zaretskii <eliz@gnu.org>
Sat, 9 Aug 2008 19:05:54 +0000 (19:05 +0000)
src/ChangeLog
src/w32.c

index 7fdffb7df384622b1f7c02fb7a50ffef55be9d28..37a405efb5cc382f725a6cea2f6a96d5de6ca162 100644 (file)
@@ -1,5 +1,8 @@
 2008-08-09  Eli Zaretskii  <eliz@gnu.org>
 
+       * w32.c (w32_system_process_attributes): If the process does not
+       exist, return nil.
+
        * w32.c: Include thelp32.h, psapi.h and coding.h.
        (_MEMORYSTATUSEX, _PROCESS_MEMORY_COUNTERS_EX): New struct
        declarations.
index 1d3c51829123b3813b094b452c9b8c78918411b3..2407cb171bed766825595cc7018ccc95ee0d31fa 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -3642,6 +3642,7 @@ w32_system_process_attributes (pid)
   Lisp_Object cmd_str, decoded_cmd, tem;
   HANDLE h_snapshot, h_proc;
   DWORD proc_id;
+  int found_proc = 0;
   char uname[UNLEN+1], gname[GNLEN+1], domain[1025];
   DWORD ulength = sizeof (uname), dlength = sizeof (domain), trash;
   DWORD glength = sizeof (gname);
@@ -3701,6 +3702,7 @@ w32_system_process_attributes (pid)
              attrs = Fcons (Fcons (Qthcount,
                                    make_fixnum_or_float (pe.cntThreads)),
                             attrs);
+             found_proc = 1;
              break;
            }
        }
@@ -3708,6 +3710,12 @@ w32_system_process_attributes (pid)
       CloseHandle (h_snapshot);
     }
 
+  if (!found_proc)
+    {
+      UNGCPRO;
+      return Qnil;
+    }
+
   h_proc = OpenProcess (PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
                        FALSE, proc_id);
   /* If we were denied a handle to the process, try again after