shane Tue Oct 29 02:32:52 2002 EDT Modified files: /TSRM tsrm_virtual_cwd.c tsrm_win32.c tsrm_win32.h Log: windows is smart enough to provide a way to set cwd for new processes. Index: TSRM/tsrm_virtual_cwd.c diff -u TSRM/tsrm_virtual_cwd.c:1.35 TSRM/tsrm_virtual_cwd.c:1.36 --- TSRM/tsrm_virtual_cwd.c:1.35 Tue Oct 22 14:57:59 2002 +++ TSRM/tsrm_virtual_cwd.c Tue Oct 29 02:32:52 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: tsrm_virtual_cwd.c,v 1.35 2002/10/22 18:57:59 iliaa Exp $ */ +/* $Id: tsrm_virtual_cwd.c,v 1.36 2002/10/29 07:32:52 shane Exp $ */ #include <sys/types.h> #include <sys/stat.h> @@ -799,33 +799,9 @@ #ifdef TSRM_WIN32 -/* On Windows the trick of prepending "cd cwd; " doesn't work so we need to perform - a real chdir() and mutex it - */ CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC) { - char prev_cwd[MAXPATHLEN]; - char *getcwd_result; - FILE *retval; - - getcwd_result = getcwd(prev_cwd, MAXPATHLEN); - if (!getcwd_result) { - return NULL; - } - -#ifdef ZTS - tsrm_mutex_lock(cwd_mutex); -#endif - - chdir(CWDG(cwd).cwd); - retval = popen(command, type); - chdir(prev_cwd); - -#ifdef ZTS - tsrm_mutex_unlock(cwd_mutex); -#endif - - return retval; + return popen_ex(command, type, CWDG(cwd).cwd, NULL); } #elif defined(NETWARE) Index: TSRM/tsrm_win32.c diff -u TSRM/tsrm_win32.c:1.13 TSRM/tsrm_win32.c:1.14 --- TSRM/tsrm_win32.c:1.13 Wed Aug 7 10:47:05 2002 +++ TSRM/tsrm_win32.c Tue Oct 29 02:32:52 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: tsrm_win32.c,v 1.13 2002/08/07 14:47:05 phanto Exp $ */ +/* $Id: tsrm_win32.c,v 1.14 2002/10/29 07:32:52 shane Exp $ */ #include <stdio.h> #include <fcntl.h> @@ -149,6 +149,11 @@ TSRM_API FILE *popen(const char *command, const char *type) { + return popen_ex(command, type, NULL, NULL); +} + +TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char +*env) +{ FILE *stream = NULL; int fno, str_len = strlen(type), read, mode; STARTUPINFO startup; @@ -190,7 +195,7 @@ cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+sizeof(" /c ")); sprintf(cmd, "%s /c %s", TWG(comspec), command); - if (!CreateProcess(NULL, cmd, &security, &security, security.bInheritHandle, NORMAL_PRIORITY_CLASS, NULL, NULL, &startup, &process)) { + if (!CreateProcess(NULL, cmd, &security, &security, security.bInheritHandle, +NORMAL_PRIORITY_CLASS, env, cwd, &startup, &process)) { return NULL; } free(cmd); Index: TSRM/tsrm_win32.h diff -u TSRM/tsrm_win32.h:1.8 TSRM/tsrm_win32.h:1.9 --- TSRM/tsrm_win32.h:1.8 Wed Aug 7 10:47:05 2002 +++ TSRM/tsrm_win32.h Tue Oct 29 02:32:52 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: tsrm_win32.h,v 1.8 2002/08/07 14:47:05 phanto Exp $ */ +/* $Id: tsrm_win32.h,v 1.9 2002/10/29 07:32:52 shane Exp $ */ #ifndef TSRM_WIN32_H #define TSRM_WIN32_H @@ -92,6 +92,7 @@ TSRM_API void tsrm_win32_startup(void); TSRM_API void tsrm_win32_shutdown(void); +TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char +*env); TSRM_API FILE *popen(const char *command, const char *type); TSRM_API int pclose(FILE *stream);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php