Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73518 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46550 invoked from network); 2 Apr 2014 13:26:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Apr 2014 13:26:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.215.10 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.215.10 mail.experimentalworks.net Received: from [217.114.215.10] ([217.114.215.10:34531] helo=mail.experimentalworks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 63/00-46235-2FF0C335 for ; Wed, 02 Apr 2014 08:26:11 -0500 Received: from [192.168.2.31] (ppp-188-174-32-124.dynamic.mnet-online.de [188.174.32.124]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: johannes@schlueters.de) by mail.experimentalworks.net (Postfix) with ESMTPSA id 05B7846424; Wed, 2 Apr 2014 15:26:56 +0200 (CEST) To: O'Neil Delpratt Cc: internals@lists.php.net In-Reply-To: <42E6A56D-0FF1-4408-BCF5-DFBCEDA735EB@saxonica.com> References: <42E6A56D-0FF1-4408-BCF5-DFBCEDA735EB@saxonica.com> Content-Type: text/plain; charset="UTF-8" Date: Wed, 02 Apr 2014 15:25:37 +0200 Message-ID: <1396445137.2982.291.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] PHP C++ extension on Windows: setting the working directory the same as PHP From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Wed, 2014-04-02 at 14:14 +0100, O'Neil Delpratt wrote: > Hi, > > I am having trouble getting the correct working directory in the C/C++ > code of my PHP extension. It should be the same as the PHP working > directory, but it is not. [...] > In linux the C function getcwd() does as expected. It is the same as > the PHP cwd, but on windows it always uses the “C:\Program Files > \Apache software Foundation\Apache2.2”, > whereas in my php script the call ‘echo getcwd();’ returns “C:\www > \html” as expected. when using Apache on Windows you are using mod_mpm which is a threaded environment. Thus there is one process which might serve multiple requests in different threads. Each thread needs (from user perspective) its own working directory, thus our thread isolation library, TSRM, provides an API for that: VCWD_GETCWD. Please see TSRM/tsrm_virtual_cwd.h for more related APIs. Mind: In 5.6 this has been moved to Zend/zend_virtual_cwd.h johannes