diff options
author | Michi Henning <michi@zeroc.com> | 2005-01-13 05:59:21 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2005-01-13 05:59:21 +0000 |
commit | d91e1d59b16b4eeb0a5c4b0780f5b4faf52dbb6d (patch) | |
tree | 0e9cc6da9482b4b0e054a809fdd3077e658cfbfd /cpp/src | |
parent | improving metadata validation (diff) | |
download | ice-d91e1d59b16b4eeb0a5c4b0780f5b4faf52dbb6d.tar.bz2 ice-d91e1d59b16b4eeb0a5c4b0780f5b4faf52dbb6d.tar.xz ice-d91e1d59b16b4eeb0a5c4b0780f5b4faf52dbb6d.zip |
Fixed bug in the way the arguments were passed to a service. I'm not sure
how this ever worked because StartService() automatically adds the
service name to argv (as argv[0]). So, as far as I can see, for a
service "X" we were always setting argv[0] *and* argv[1] to "X". But
then, it's only since we added IceUtil::Options that we are more
stringent with argument passing, so this may have slipped through
somehow previously.
Diffstat (limited to 'cpp/src')
-rwxr-xr-x | cpp/src/Ice/Service.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp index f3dc33210b4..bb27af31740 100755 --- a/cpp/src/Ice/Service.cpp +++ b/cpp/src/Ice/Service.cpp @@ -260,16 +260,16 @@ Ice::Service::main(int& argc, char* argv[]) } vector<string> args; - for(idx = 1; idx < argc; ++idx) - { - args.push_back(argv[idx]); - } // - // Append the arguments "--service NAME" so that the service + // Prepend the arguments "--service NAME" so that the service // starts properly. // args.push_back("--service"); args.push_back(name); + for(idx = 1; idx < argc; ++idx) + { + args.push_back(argv[idx]); + } return installService(name, display, executable, args); } else if(op == "--uninstall") @@ -657,12 +657,13 @@ Ice::Service::startService(const string& name, const vector<string>& args) } // - // Create argument vector. + // Create argument vector. Note that StartService() automatically adds the service name + // in argv[0], so the argv that is passed to StartService() must *not* include the + // the service name in argv[0]. // - const int argc = args.size() + 1; + const int argc = args.size(); LPCSTR* argv = new LPCSTR[argc]; - argv[0] = strdup(name.c_str()); - int i = 1; + int i = 0; for(vector<string>::const_iterator p = args.begin(); p != args.end(); ++p) { argv[i++] = strdup(p->c_str()); @@ -783,6 +784,7 @@ Ice::Service::startService(const string& name, const vector<string>& args) << " Check point: " << status.dwCheckPoint << endl << " Wait hint: " << status.dwWaitHint; trace(ostr.str()); + return EXIT_FAILURE; } return EXIT_SUCCESS; @@ -1120,8 +1122,7 @@ Ice::Service::serviceMain(int argc, char* argv[]) } catch(const Ice::Exception& ex) { - // TODO: Enable delete when we figure out why it can cause a crash. - // delete[] args; + delete[] args; ostringstream ostr; ostr << ex; error(ostr.str()); @@ -1186,8 +1187,7 @@ Ice::Service::serviceMain(int argc, char* argv[]) error("service caught unhandled C++ exception"); } - // TODO: Enable delete when we figure out why it can cause a crash. - // delete[] args; + delete[] args; try { |