From: Davin McCall Date: Wed, 7 Aug 2019 11:39:21 +0000 (+1000) Subject: dinitctl: update restart handling. X-Git-Tag: v0.7.0~6 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=47a7a21e3376323d9614d6d6b063ef5a7dddb79b;p=oweals%2Fdinit.git dinitctl: update restart handling. As per changes in dinit daemon/control protocol. --- diff --git a/src/dinitctl.cc b/src/dinitctl.cc index f260bf0..e2c867f 100644 --- a/src/dinitctl.cc +++ b/src/dinitctl.cc @@ -552,8 +552,10 @@ static int start_stop_service(int socknum, cpbuffer_t &rbuffer, const char *serv return 0; // success! } if (reply_pkt_h == DINIT_RP_DEPENDENTS && pcommand == DINIT_CP_STOPSERVICE) { - cerr << "dinitctl: Cannot stop service due to the following dependents:\n" - "(Only direct dependents are listed. Exercise caution before using '--force' !!)\n"; + cerr << "dinitctl: cannot stop service due to the following dependents:\n"; + if (command != command_t::RESTART_SERVICE) { + cerr << "(Only direct dependents are listed. Exercise caution before using '--force' !!)\n"; + } // size_t number, N * handle_t handles size_t number; rbuffer.fill_to(socknum, sizeof(number)); @@ -576,6 +578,10 @@ static int start_stop_service(int socknum, cpbuffer_t &rbuffer, const char *serv cerr << "\n"; return 1; } + if (reply_pkt_h == DINIT_RP_NAK && command == command_t::RESTART_SERVICE) { + cerr << "dinitctl: cannot restart service; service not started.\n"; + return 1; + } if (reply_pkt_h != DINIT_RP_ACK && reply_pkt_h != DINIT_RP_ALREADYSS) { cerr << "dinitctl: protocol error." << endl; return 1; diff --git a/src/igr-tests/force-stop/expected-2.err b/src/igr-tests/force-stop/expected-2.err index 561b7d2..b643b27 100644 --- a/src/igr-tests/force-stop/expected-2.err +++ b/src/igr-tests/force-stop/expected-2.err @@ -1,3 +1,3 @@ -dinitctl: Cannot stop service due to the following dependents: +dinitctl: cannot stop service due to the following dependents: (Only direct dependents are listed. Exercise caution before using '--force' !!) intermediary boot