summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Ice/Application.cpp26
-rw-r--r--cpp/src/Ice/Service.cpp62
2 files changed, 71 insertions, 17 deletions
diff --git a/cpp/src/Ice/Application.cpp b/cpp/src/Ice/Application.cpp
index 5a2a80805f0..0b1f40439e0 100644
--- a/cpp/src/Ice/Application.cpp
+++ b/cpp/src/Ice/Application.cpp
@@ -280,12 +280,20 @@ Ice::Application::main(int argc, char* argv[], const char* configFile)
}
catch(const std::exception& ex)
{
- cerr << argv[0] << ": " << ex.what() << endl;
+ if(argv[0])
+ {
+ cerr << argv[0] << ": ";
+ }
+ cerr << ex.what() << endl;
return EXIT_FAILURE;
}
catch(...)
{
- cerr << argv[0] << ": unknown exception" << endl;
+ if(argv[0])
+ {
+ cerr << argv[0] << ": ";
+ }
+ cerr << "unknown exception" << endl;
return EXIT_FAILURE;
}
}
@@ -297,7 +305,11 @@ Ice::Application::main(int argc, char* argv[], const InitializationData& initDat
{
if(_communicator != 0)
{
- cerr << argv[0] << ": only one instance of the Application class can be used" << endl;
+ if(argv[0])
+ {
+ cerr << argv[0] << ": ";
+ }
+ cerr << "only one instance of the Application class can be used" << endl;
return EXIT_FAILURE;
}
int status;
@@ -322,7 +334,11 @@ Ice::Application::main(int argc, char* argv[], const InitializationData& initDat
}
catch(const CtrlCHandlerException&)
{
- cerr << argv[0] << ": only one instance of the Application class can be used" << endl;
+ if(argv[0])
+ {
+ cerr << argv[0] << ": ";
+ }
+ cerr << "only one instance of the Application class can be used" << endl;
status = EXIT_FAILURE;
}
}
@@ -539,7 +555,7 @@ Ice::Application::mainInternal(int argc, char* argv[], const InitializationData&
}
_interrupted = false;
- _appName = argv[0];
+ _appName = argv[0] ? argv[0] : "";
//
// We parse the properties here to extract Ice.ProgramName.
diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp
index 78d5ce38950..44009d2dfd8 100644
--- a/cpp/src/Ice/Service.cpp
+++ b/cpp/src/Ice/Service.cpp
@@ -382,7 +382,7 @@ Ice::Service::interrupt()
int
Ice::Service::main(int& argc, char* argv[], const InitializationData& initializationData)
{
- _name = argv[0];
+ _name = argv[0] ? argv[0] : "";
//
// We parse the properties here to extract Ice.ProgramName and
@@ -656,7 +656,11 @@ Ice::Service::main(int& argc, char* argv[], const InitializationData& initializa
}
else
{
- cerr << argv[0] << ": --pidfile must be followed by an argument" << endl;
+ if(argv[0])
+ {
+ cerr << argv[0] << ": ";
+ }
+ cerr << "--pidfile must be followed by an argument" << endl;
return EXIT_FAILURE;
}
@@ -674,13 +678,21 @@ Ice::Service::main(int& argc, char* argv[], const InitializationData& initializa
if(!closeFiles && !daemonize)
{
- cerr << argv[0] << ": --noclose must be used with --daemon" << endl;
+ if(argv[0])
+ {
+ cerr << argv[0] << ": ";
+ }
+ cerr << "--noclose must be used with --daemon" << endl;
return EXIT_FAILURE;
}
if(pidFile.size() > 0 && !daemonize)
{
- cerr << argv[0] << ": --pidfile <file> must be used with --daemon" << endl;
+ if(argv[0])
+ {
+ cerr << argv[0] << ": ";
+ }
+ cerr << "--pidfile <file> must be used with --daemon" << endl;
return EXIT_FAILURE;
}
@@ -1227,7 +1239,10 @@ Ice::Service::syserror(const string& msg)
}
else
{
- cerr << _name << ": ";
+ if(!_name.empty())
+ {
+ cerr << _name << ": ";
+ }
if(!msg.empty())
{
cerr << msg << endl;
@@ -1248,7 +1263,11 @@ Ice::Service::error(const string& msg)
}
else
{
- cerr << _name << ": error: " << msg << endl;
+ if(!_name.empty())
+ {
+ cerr << _name << ": ";
+ }
+ cerr << "error: " << msg << endl;
}
}
@@ -1261,7 +1280,11 @@ Ice::Service::warning(const string& msg)
}
else
{
- cerr << _name << ": warning: " << msg << endl;
+ if(!_name.empty())
+ {
+ cerr << _name << ": ";
+ }
+ cerr << "warning: " << msg << endl;
}
}
@@ -1749,7 +1772,11 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
pid_t pid = fork();
if(pid < 0)
{
- cerr << argv[0] << ": " << strerror(errno) << endl;
+ if(argv[0])
+ {
+ cerr << argv[0] << ": ";
+ }
+ cerr << strerror(errno) << endl;
return EXIT_FAILURE;
}
@@ -1778,7 +1805,11 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
continue;
}
- cerr << argv[0] << ": " << strerror(errno) << endl;
+ if(argv[0])
+ {
+ cerr << argv[0] << ": ";
+ }
+ cerr << strerror(errno) << endl;
_exit(EXIT_FAILURE);
}
break;
@@ -1801,14 +1832,21 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
continue;
}
- cerr << argv[0] << ": I/O error while reading error message from child:\n"
- << strerror(errno) << endl;
+ if(argv[0])
+ {
+ cerr << ": ";
+ }
+ cerr << "I/O error while reading error message from child:\n" << strerror(errno) << endl;
_exit(EXIT_FAILURE);
}
pos += n;
break;
}
- cerr << argv[0] << ": failure occurred in daemon";
+ if(argv[0])
+ {
+ cerr << argv[0] << ": ";
+ }
+ cerr << "failure occurred in daemon";
if(strlen(msg) > 0)
{
cerr << ':' << endl << msg;