From dad709122a913b2f7e7dbd55f9295cb4dbfe16df Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sun, 16 Jul 2000 15:42:22 +0000 Subject: [PATCH] Transmit current directory settings to newly created processes. --- include/process.h | 3 ++- loader/module.c | 7 ++----- scheduler/process.c | 22 +++++++++++++++++++--- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/include/process.h b/include/process.h index ea1994f14f2..b98cf9f7f55 100644 --- a/include/process.h +++ b/include/process.h @@ -155,7 +155,8 @@ extern void PROCESS_CallUserSignalProc( UINT uCode, HMODULE hModule ); extern BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env, LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa, BOOL inherit, DWORD flags, - STARTUPINFOA *startup, PROCESS_INFORMATION *info ); + STARTUPINFOA *startup, PROCESS_INFORMATION *info, + LPCSTR lpCurrentDirectory ); static inline PDB WINE_UNUSED *PROCESS_Current(void) { diff --git a/loader/module.c b/loader/module.c index 65db9cf3424..ebfd12357ac 100644 --- a/loader/module.c +++ b/loader/module.c @@ -949,9 +949,6 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine, FIXME("(%s,...): PROFILE_KERNEL ignored\n", name); if (dwCreationFlags & PROFILE_SERVER) FIXME("(%s,...): PROFILE_SERVER ignored\n", name); - if (lpCurrentDirectory) - FIXME("(%s,...): lpCurrentDirectory %s ignored\n", - name, lpCurrentDirectory); if (lpStartupInfo->lpDesktop) FIXME("(%s,...): lpStartupInfo->lpDesktop %s ignored\n", name, lpStartupInfo->lpDesktop); @@ -984,7 +981,7 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine, retv = PROCESS_Create( -1, name, tidy_cmdline, lpEnvironment, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, - lpStartupInfo, lpProcessInfo ); + lpStartupInfo, lpProcessInfo, lpCurrentDirectory ); goto done; } @@ -998,7 +995,7 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine, retv = PROCESS_Create( hFile, name, tidy_cmdline, lpEnvironment, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, - lpStartupInfo, lpProcessInfo ); + lpStartupInfo, lpProcessInfo, lpCurrentDirectory); break; case SCS_PIF_BINARY: diff --git a/scheduler/process.c b/scheduler/process.c index 3334591c540..8aea56c144f 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -674,7 +674,8 @@ static void exec_wine_binary( char **argv, char **envp ) * * Fork and exec a new Unix process, checking for errors. */ -static int fork_and_exec( const char *filename, char *cmdline, const char *env ) +static int fork_and_exec( const char *filename, char *cmdline, + const char *env, const char *newdir ) { int fd[2]; int pid, err; @@ -690,6 +691,9 @@ static int fork_and_exec( const char *filename, char *cmdline, const char *env ) char **argv = build_argv( cmdline, filename ? 0 : 2 ); char **envp = build_envp( env ); close( fd[0] ); + + if (newdir) chdir(newdir); + if (argv && envp) { if (!filename) @@ -725,10 +729,11 @@ static int fork_and_exec( const char *filename, char *cmdline, const char *env ) BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env, LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa, BOOL inherit, DWORD flags, LPSTARTUPINFOA startup, - LPPROCESS_INFORMATION info ) + LPPROCESS_INFORMATION info, LPCSTR lpCurrentDirectory ) { int pid; const char *unixfilename = NULL; + const char *unixdir = NULL; DOS_FULL_NAME full_name; HANDLE load_done_evt = -1; struct new_process_request *req = get_req_buffer(); @@ -757,6 +762,17 @@ BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env, req->cmd_show = startup->wShowWindow; req->alloc_fd = 0; + if (lpCurrentDirectory) { + if (DOSFS_GetFullName( lpCurrentDirectory, TRUE, &full_name )) + unixdir = full_name.long_name; + } else { + CHAR buf[260]; + if (GetCurrentDirectoryA(sizeof(buf),buf)) { + if (DOSFS_GetFullName( buf, TRUE, &full_name )) + unixdir = full_name.long_name; + } + } + if (hFile == -1) /* unix process */ { unixfilename = filename; @@ -772,7 +788,7 @@ BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env, /* fork and execute */ - pid = fork_and_exec( unixfilename, cmd_line, env ? env : GetEnvironmentStringsA() ); + pid = fork_and_exec( unixfilename, cmd_line, env ? env : GetEnvironmentStringsA(), unixdir ); wait_req->cancel = (pid == -1); wait_req->pinherit = (psa && (psa->nLength >= sizeof(*psa)) && psa->bInheritHandle);