Skip to content

Commit 032ee97

Browse files
committed
[rootx] Don't use full path in root.exe invocation
If the `root` executable was in the path and could be started, the `root.exe` is in the path to because they are in the same directory. Therefore it's not necessary to start `root.exe` with the full path.
1 parent b679891 commit 032ee97

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

rootx/src/rootx.cxx

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@
4040
#include <libprocstat.h>
4141
#endif // R__FBSD
4242

43-
#if defined(__CYGWIN__) && defined(__GNUC__)
44-
#define ROOTBINARY "root_exe.exe"
45-
#else
46-
#define ROOTBINARY "root.exe"
47-
#endif
48-
4943
static int gChildpid;
5044
static int GetErrno()
5145
{
@@ -160,9 +154,6 @@ static void PrintUsage()
160154

161155
int main(int argc, char **argv)
162156
{
163-
char **argvv;
164-
char arg0[kMAXPATHLEN];
165-
166157
#ifdef ROOTPREFIX
167158
if (std::getenv("ROOTIGNOREPREFIX")) {
168159
#endif
@@ -241,29 +232,21 @@ int main(int argc, char **argv)
241232
// Child is going to overlay itself with the actual ROOT module...
242233

243234
// Build argv vector
244-
argvv = new char* [argc+1];
245-
#ifdef ROOTBINDIR
246-
if (std::getenv("ROOTIGNOREPREFIX"))
247-
#endif
248-
snprintf(arg0, sizeof(arg0), "%s/bin/%s", std::getenv("ROOTSYS"), ROOTBINARY);
249-
#ifdef ROOTBINDIR
250-
else
251-
snprintf(arg0, sizeof(arg0), "%s/%s", ROOTBINDIR, ROOTBINARY);
252-
#endif
235+
char arg0[] = "root.exe\0";
236+
237+
std::vector<char *> argvv(argc+1);
253238
argvv[0] = arg0;
254239

255240
for (i = 1; i < argc; i++)
256241
argvv[i] = argv[i];
257242
argvv[i] = 0;
258243

259244
// Execute actual ROOT module
260-
execv(arg0, argvv);
245+
execv("root.exe", argvv.data());
261246

262247
// Exec failed
263-
fprintf(stderr, "%s: can't start ROOT -- check that %s exists!\n",
264-
argv[0], arg0);
265-
266-
delete [] argvv;
248+
fprintf(stderr, "%s: can't start ROOT -- check that root.exe exists!\n",
249+
argv[0]);
267250

268251
return 1;
269252
}

0 commit comments

Comments
 (0)