@@ -51,64 +51,6 @@ static void ResetErrno()
5151 errno = 0 ;
5252}
5353
54- static const char *GetExePath ()
55- {
56- static std::string exepath;
57- if (exepath == " " ) {
58- #ifdef __APPLE__
59- exepath = _dyld_get_image_name (0 );
60- #endif
61- #ifdef __linux
62- char linkname[64 ]; // /proc/<pid>/exe
63- char buf[kMAXPATHLEN ]; // exe path name
64- pid_t pid;
65-
66- // get our pid and build the name of the link in /proc
67- pid = getpid ();
68- snprintf (linkname,64 , " /proc/%i/exe" , pid);
69- int ret = readlink (linkname, buf, kMAXPATHLEN );
70- if (ret > 0 && ret < kMAXPATHLEN ) {
71- buf[ret] = 0 ;
72- exepath = buf;
73- }
74- #endif
75- #if defined(R__FBSD)
76- procstat* ps = procstat_open_sysctl (); //
77- kinfo_proc* kp = kinfo_getproc (getpid ());
78-
79- if (kp!=NULL ) {
80- char path_str[PATH_MAX] = " " ;
81- procstat_getpathname (ps, kp, path_str, sizeof (path_str));
82- exepath = path_str;
83- }
84-
85- free (kp);
86- procstat_close (ps);
87- #endif
88- }
89- return exepath.c_str ();
90- }
91-
92- static void SetRootSys ()
93- {
94- const char *exepath = GetExePath ();
95- if (exepath && *exepath) {
96- std::string epStr{exepath};
97- char *ep = epStr.data ();
98- char *s;
99- if ((s = strrchr (ep, ' /' ))) {
100- *s = 0 ;
101- if ((s = strrchr (ep, ' /' ))) {
102- *s = 0 ;
103- int l2 = strlen (ep) + 10 ;
104- char *env = new char [l2];
105- snprintf (env, l2, " ROOTSYS=%s" , ep);
106- putenv (env); // NOLINT: allocated memory now used by environment variable
107- }
108- }
109- }
110- }
111-
11254extern " C" {
11355 static void SigTerm (int );
11456}
@@ -154,21 +96,6 @@ static void PrintUsage()
15496
15597int main (int argc, char **argv)
15698{
157- #ifdef ROOTPREFIX
158- if (std::getenv (" ROOTIGNOREPREFIX" )) {
159- #endif
160- // Try to set ROOTSYS depending on pathname of the executable
161- SetRootSys ();
162-
163- if (!std::getenv (" ROOTSYS" )) {
164- fprintf (stderr, " %s: ROOTSYS not set. Set it before trying to run %s.\n " ,
165- argv[0 ], argv[0 ]);
166- return 1 ;
167- }
168- #ifdef ROOTPREFIX
169- }
170- #endif
171-
17299 // In batch mode don't show splash screen, idem for no logo mode,
173100 // in about mode show always splash screen
174101 int i;
0 commit comments