X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
Date: Wed, 18 Aug 2010 21:38:10 +0200
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: "run" changes behavior with cygwin-17.6
Message-ID: <20100818193810.GD11340@calimero.vinschen.de>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <380-220108318145158645@cantv.net> <20100818150920.GY11340@calimero.vinschen.de> <4C6C1490.3040202@cwilson.fastmail.fm> <4C6C1582.1080801@acm.org> <20100818182412.GA22698@ednor.casa.cgf.cx> <AANLkTikBTgg9M=xuZ4S2VkNU+Zr=hy3C=_Tr8BPj5baD@mail.gmail.com> <20100818185421.GC22698@ednor.casa.cgf.cx> <20100818191340.GB11340@calimero.vinschen.de> <20100818191906.GD22698@ednor.casa.cgf.cx>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
In-Reply-To: <20100818191906.GD22698@ednor.casa.cgf.cx>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On Aug 18 15:19, Christopher Faylor wrote:
> On Wed, Aug 18, 2010 at 09:13:40PM +0200, Corinna Vinschen wrote:
> >I'm going to add a new call
> >
> >  cygwin_internal (CW_SYNC_WINCWD);
> >
> >which will do the same for the CWD as
> >
> >  cygwin_internal (CW_SYNC_WINENV);
> 
> Actually I just checked in "CW_SETCWD" which just calls
> SetCurrentDirectoryW.  I was just going to request trying a snapshot
> when I saw your message.

Oh.  Shouldn't SetCurrentDirectoryW only be called if cygheap->cwd.get_error
is 0?  Here's what I had in mind:

Index: external.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/external.cc,v
retrieving revision 1.116
diff -u -p -r1.116 external.cc
--- external.cc	4 Jul 2010 17:12:26 -0000	1.116
+++ external.cc	18 Aug 2010 19:37:33 -0000
@@ -162,6 +162,24 @@ sync_winenv ()
   free (envblock);
 }
 
+/* Synchronize Win32 CWD with Cygwin CWD.  Return -1 and set errno if
+   setting the Win32 CWD fails. */
+static unsigned long
+sync_wincwd ()
+{
+  if (cygheap->cwd.get_error ())
+    {
+      set_errno (cygheap->cwd.get_error ());
+      return (unsigned long) -1;
+    }
+  if (!SetCurrentDirectoryW (cygheap->cwd.win32.Buffer))
+    {
+      __seterrno ();
+      return (unsigned long) -1;
+    }
+  return 0;
+}
+
 /*
  * Cygwin-specific wrapper for win32 ExitProcess and TerminateProcess.
  * It ensures that the correct exit code, derived from the specified
@@ -514,6 +532,9 @@ cygwin_internal (cygwin_getinfo_types t,
 	  res = (uintptr_t) strerror (err);
 	}
 	break;
+      case CW_SYNC_WINCWD:
+	res = sync_wincwd ();
+	break;
 
       default:
 	set_errno (ENOSYS);


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
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

