39int main(
int argc,
char **argv)
43 fprintf(stderr,
"%s: insufficient input:"
44 " client URL must to be provided\n",
gAppName);
53 loglevel = argdbg.
Atoi();
56 fprintf(stderr,
"%s: Starting remote session on %s\n",
gAppName,
gSystem->HostName());
58 fprintf(stderr,
"%s: argc: %d\n",
gAppName, argc);
59 for (
Int_t i = 0; i < argc; i++)
60 fprintf(stderr,
"%s: argv[%d]: %s\n",
gAppName, i, argv[i]);
66 fprintf(stderr,
"%s: Error: failed to create cleanup script\n",
gAppName);
73 fprintf(stderr,
"%s: output redirected to %s\n",
gAppName,
logfile.Data());
75 fprintf(stderr,
"%s: problems redirecting output\n",
gAppName);
88 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TApplication",
"server"))) {
89 if (
h->LoadPlugin() == 0) {
92 fprintf(stderr,
"%s: failed to load plugin for TApplicationServer\n",
gAppName);
95 fprintf(stderr,
"%s: failed to find plugin for TApplicationServer\n",
gAppName);
102 fprintf(stderr,
"%s: failed to instantiate TApplicationServer\n",
gAppName);
118 fprintf(stderr,
"%s: RedirectOutput: enter\n", loc);
123 const char *lfn =
logfile.Data();
125 fprintf(stderr,
"%s: Path to log file: %s\n", loc, lfn);
128 fprintf(stderr,
"%s: RedirectOutput: reopen %s\n", loc, lfn);
129 FILE *flog = freopen(lfn,
"w", stdout);
131 fprintf(stderr,
"%s: RedirectOutput: could not freopen stdout\n", loc);
136 fprintf(stderr,
"%s: RedirectOutput: dup2 ...\n", loc);
137 if ((dup2(fileno(stdout), fileno(stderr))) < 0) {
138 fprintf(stderr,
"%s: RedirectOutput: could not redirect stderr\n", loc);
143 fprintf(stderr,
"%s: RedirectOutput: read open ...\n", loc);
144 FILE *fLog = fopen(lfn,
"r");
146 fprintf(stderr,
"%s: RedirectOutput: could not open logfile %s\n", loc, lfn);
151 fprintf(stderr,
"%s: RedirectOutput: done!\n", loc);
166 FILE *fc = fopen(cleanup.
Data(),
"w");
168 fprintf(fc,
"#!/bin/sh\n");
170 fprintf(fc,
"# Cleanup script for roots process %d\n",
gSystem->GetPid());
171 fprintf(fc,
"# Usage:\n");
172 fprintf(fc,
"# ssh %s@%s %s\n",
gSystem->Getenv(
"USER"),
gSystem->HostName(), cleanup.
Data());
174 fprintf(fc,
"kill -9 %d",
gSystem->GetPid());
177 if (chmod(cleanup.
Data(), S_IRUSR | S_IWUSR | S_IXUSR) != 0) {
178 fprintf(stderr,
"%s: Error: cannot make script %s executable\n",
gAppName, cleanup.
Data());
179 unlink(cleanup.
Data());
183 fprintf(stderr,
"%s: Path to cleanup script %s\n",
gAppName, cleanup.
Data());
186 fprintf(stderr,
"%s: Error: file %s could not be created\n",
gAppName, cleanup.
Data());
int Int_t
Signed integer 4 bytes (int).
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop. Calls system dependent eventloop via gSystem.
Int_t Atoi() const
Return integer value of string.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
static std::string logfile
static Int_t MakeCleanupScript(Int_t loglevel)
Create a script that can be executed to cleanup this process in case of problems.
static FILE * RedirectOutput(TString &logfile, const char *loc)
Redirect stdout to 'logfile'.
static const char * gAppName