Use argv[0] to locate the server executable.
diff --git a/debugger/dbgmain.c b/debugger/dbgmain.c
index 084ad92..aa84e8e 100644
--- a/debugger/dbgmain.c
+++ b/debugger/dbgmain.c
@@ -199,7 +199,6 @@
int
main(int argc, char * argv[])
{
- extern char * DEBUG_argv0;
SIGCONTEXT reg;
strcpy(vdv, "This is a test");
@@ -207,7 +206,7 @@
vvv.whatsup = 0;
vvv.flag3 = 0;
vvv.remain = 0x401;
- DEBUG_argv0 = argv[0];
+ argv0 = argv[0];
xxx = (unsigned int*) &vvv;
yyy = xxx + 5;
xxx3[5] = 7;
diff --git a/debugger/stabs.c b/debugger/stabs.c
index cb5f7f0..d77ae6d 100644
--- a/debugger/stabs.c
+++ b/debugger/stabs.c
@@ -24,6 +24,7 @@
#define PATH_MAX _MAX_PATH
#endif
+#include "options.h"
#include "debugger.h"
#if defined(__svr4__) || defined(__sun)
@@ -70,10 +71,6 @@
#define N_EXCL 0xc2
#define N_RBRAC 0xe0
-/*
- * Set so that we know the main executable name and path.
- */
-char * DEBUG_argv0;
struct stab_nlist {
union {
@@ -1317,7 +1314,7 @@
DEBUG_ReadExecutableDbgInfo(void)
{
Elf32_Ehdr * ehdr;
- char * exe_name;
+ const char * exe_name;
Elf32_Dyn * dynpnt;
struct r_debug * dbg_hdr;
struct link_map * lpnt = NULL;
@@ -1329,7 +1326,7 @@
int rtn = FALSE;
int rowcount;
- exe_name = DEBUG_argv0;
+ exe_name = argv0;
/*
* Make sure we can stat and open this file.
@@ -1426,7 +1423,7 @@
int status;
unsigned int stroff;
- exe_name = DEBUG_argv0;
+ exe_name = argv0;
/*
* Make sure we can stat and open this file.
diff --git a/dlls/crtdll/crtdll_main.c b/dlls/crtdll/crtdll_main.c
index b2c636a..d62e8b1 100644
--- a/dlls/crtdll/crtdll_main.c
+++ b/dlls/crtdll/crtdll_main.c
@@ -971,7 +971,7 @@
unsigned char *bp;
int i;
- sprintf( buffer, "%s \"", Options.argv0 );
+ sprintf( buffer, "%s \"", argv0 );
bp = buffer + strlen(buffer);
i = strlen(buffer) + strlen(x) +2;
diff --git a/include/options.h b/include/options.h
index edd49c2..c7ee80e 100644
--- a/include/options.h
+++ b/include/options.h
@@ -58,7 +58,6 @@
char **argv;
char * desktopGeometry; /* NULL when no desktop */
char * programName; /* To use when loading resources */
- char * argv0; /* argv[0] of Wine process */
char *dllFlags; /* -dll flags (hack for Winelib support) */
int usePrivateMap;
int useFixedMap;
@@ -81,6 +80,7 @@
};
extern struct options Options;
+extern const char *argv0;
/* Profile functions */
diff --git a/loader/dos/module.c b/loader/dos/module.c
index b488063..6584370 100644
--- a/loader/dos/module.c
+++ b/loader/dos/module.c
@@ -432,7 +432,7 @@
/* now load dosmod */
/* check argv[0]-derived paths first, since the newest dosmod is most likely there
* (at least it was once for Andreas Mohr, so I decided to make it easier for him) */
- fpath=strrchr(strcpy(path,Options.argv0),'/');
+ fpath=strrchr(strcpy(path,argv0),'/');
if (fpath) {
strcpy(fpath,"/dosmod");
execl(path,fname,farg,NULL);
diff --git a/loader/main.c b/loader/main.c
index 9d6b9ad..c3d7cc3 100644
--- a/loader/main.c
+++ b/loader/main.c
@@ -58,6 +58,9 @@
*/
BOOL MAIN_MainInit( int *argc, char *argv[] )
{
+ /* store the program name */
+ argv0 = argv[0];
+
/* Create the initial process */
if (!PROCESS_Init()) return 0;
diff --git a/misc/main.c b/misc/main.c
index d24cc4b..a0254a7 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -84,7 +84,6 @@
NULL, /* argv */
NULL, /* desktopGeometry */
NULL, /* programName */
- NULL, /* argv0 */
NULL, /* dllFlags */
FALSE, /* usePrivateMap */
FALSE, /* useFixedMap */
@@ -107,7 +106,9 @@
0 /* screenDepth */
};
-static char szUsage[] =
+const char *argv0;
+
+static const char szUsage[] =
"%s\n"
"Usage: %s [options] \"program_name [arguments]\"\n"
"\n"
@@ -737,7 +738,6 @@
Options.argc = argc;
Options.argv = argv;
Options.programName = MAIN_GetProgramName( *argc, argv );
- Options.argv0 = argv[0];
/* initialise Options.language to 0 to tell "no language choosen yet" */
Options.language = 0;
diff --git a/miscemu/main.c b/miscemu/main.c
index 44cede0..675826d 100644
--- a/miscemu/main.c
+++ b/miscemu/main.c
@@ -107,13 +107,6 @@
int main( int argc, char *argv[] )
{
NE_MODULE *pModule;
- extern char * DEBUG_argv0;
-
- /*
- * Save this so that the internal debugger can get a hold of it if
- * it needs to.
- */
- DEBUG_argv0 = argv[0];
/* Set up debugger hook */
EXC_SetDebugEventHook( wine_debugger );
diff --git a/scheduler/client.c b/scheduler/client.c
index e8dda19..d801aff 100644
--- a/scheduler/client.c
+++ b/scheduler/client.c
@@ -307,9 +307,22 @@
if (pid == -1) fatal_perror( "fork" );
if (!pid)
{
+ char *path, *p;
+ /* first try the installation dir */
execl( BINDIR "/wineserver", "wineserver", NULL );
if (oldcwd) chdir( oldcwd );
+ /* now try the dir we were launched from */
+ path = xmalloc( strlen(argv0) + 20 );
+ if ((p = strrchr( strcpy( path, argv0 ), '/' )))
+ {
+ strcpy( p, "/wineserver" );
+ execl( path, "wineserver", NULL );
+ strcpy( p, "/server/wineserver" );
+ execl( path, "wineserver", NULL );
+ }
+ /* now try the path */
execlp( "wineserver", "wineserver", NULL );
+ /* and finally the current dir */
execl( "./server/wineserver", "wineserver", NULL );
fatal_error( "could not exec wineserver\n" );
}
diff --git a/windows/x11drv/monitor.c b/windows/x11drv/monitor.c
index 69a617e..5580aac 100644
--- a/windows/x11drv/monitor.c
+++ b/windows/x11drv/monitor.c
@@ -114,7 +114,7 @@
wm_hints->flags = InputHint | StateHint;
wm_hints->input = True;
wm_hints->initial_state = NormalState;
- class_hints->res_name = Options.argv[0]; /* FIXME: Options.argv0 insteed? */
+ class_hints->res_name = argv0;
class_hints->res_class = "Wine";
TSXStringListToTextProperty( &name, 1, &window_name );