OSDN Git Service

* exceptions.cc (open_stackdumpfile): Don't try to open file if we
authorcorinna <corinna>
Wed, 18 Aug 2010 14:22:06 +0000 (14:22 +0000)
committercorinna <corinna>
Wed, 18 Aug 2010 14:22:06 +0000 (14:22 +0000)
have no filesystem based CWD.  Add comment.
* path.cc (cwdstuff::set): Set CWD handle to NULL if CWD is a virtual
path.  Simplify matching comment.

winsup/cygwin/ChangeLog
winsup/cygwin/exceptions.cc
winsup/cygwin/path.cc

index a49f03e..c4284bd 100644 (file)
@@ -1,5 +1,12 @@
 2010-08-18  Corinna Vinschen  <corinna@vinschen.de>
 
+       * exceptions.cc (open_stackdumpfile): Don't try to open file if we
+       have no filesystem based CWD.  Add comment.
+       * path.cc (cwdstuff::set): Set CWD handle to NULL if CWD is a virtual
+       path.  Simplify matching comment.
+
+2010-08-18  Corinna Vinschen  <corinna@vinschen.de>
+
        * fhandler_disk_file.cc (fhandler_base::fstat_helper): Set st_rdev
        to correct device number for fs_special devices.
 
index a2afa5e..e904ff1 100644 (file)
@@ -128,7 +128,10 @@ error_start_init (const char *buf)
 static void
 open_stackdumpfile ()
 {
-  if (myself->progname[0])
+  /* If we have no executable name, or if the CWD handle is NULL,
+     which means, the CWD is a virtual path, don't even try to open
+     a stackdump file. */
+  if (myself->progname[0] && cygheap->cwd.get_handle ())
     {
       const WCHAR *p;
       /* write to progname.stackdump if possible */
index ee7d186..00a9c1d 100644 (file)
@@ -3321,9 +3321,9 @@ cwdstuff::set (path_conv *nat_cwd, const char *posix_cwd)
   /* Open a directory handle with FILE_OPEN_FOR_BACKUP_INTENT and with all
      sharing flags set.  The handle is right now used in exceptions.cc only,
      but that might change in future. */
+  HANDLE h = NULL;
   if (!virtual_path)
     {
-      HANDLE h;
       NTSTATUS status;
       IO_STATUS_BLOCK io;
       OBJECT_ATTRIBUTES attr;
@@ -3363,18 +3363,11 @@ cwdstuff::set (path_conv *nat_cwd, const char *posix_cwd)
          __seterrno_from_nt_status (status);
          return -1;
        }
-      /* Note that we don't set the dir handle to NULL for virtual paths.
-        The handle is used to generate a stackdump file.  Since we can't
-        create a stackdump in a virtual path, we have at least *some*
-        directory handle to generate the stackdump in.
-
-        However, note that we have to make sure that we don't use the handle
-        wrongly as soon as we start to use it in other cases as well. */
-      HANDLE old_dir = dir;
-      dir = h;
-      if (old_dir)
-       NtClose (old_dir);
     }
+  /* Set new handle.  It's only used when creating stackdumps so far. */
+  if (dir)
+    NtClose (dir);
+  dir = h;
 
   if (!nat_cwd)
     {