.fi
The << and >> symbols represent a transition state (starting and stopping respectively); curly braces
-indicate the desired state (left: started, right: stopped).
+indicate the desired state (left: started, right: stopped). An 's' in place of '+' means that service
+startup was skipped (possible only if the service is configured as skippable). An 'X' in place of '-'
+means that the service failed to start, or that the service process unexpectedly terminated with an
+error status or signal while running.
+
+Additional information, if available, will be printed after the service name: whether the service owns,
+or is waiting to acquire, the console; the process ID; the exit status or signal that caused termination.
.RE
.TP
\fBshutdown\fR
int console_flags = rbuffer[4];
bool has_console = (console_flags & 2) != 0;
bool waiting_console = (console_flags & 1) != 0;
+ bool was_skipped = (console_flags & 4) != 0;
- // stopped_reason_t stop_reason = static_cast<stopped_reason_t>(rbuffer[5]);
+ stopped_reason_t stop_reason = static_cast<stopped_reason_t>(rbuffer[5]);
pid_t service_pid;
int exit_status;
cout << "[";
cout << (target == service_state_t::STARTED ? "{" : " ");
- cout << (current == service_state_t::STARTED ? "+" : " ");
+ if (current == service_state_t::STARTED) {
+ cout << (was_skipped ? "s" : "+");
+ }
+ else {
+ cout << " ";
+ }
cout << (target == service_state_t::STARTED ? "}" : " ");
if (current == service_state_t::STARTING) {
}
cout << (target == service_state_t::STOPPED ? "{" : " ");
- cout << (current == service_state_t::STOPPED ? "-" : " ");
+ if (current == service_state_t::STOPPED) {
+ bool did_fail = false;
+ if (stop_reason == stopped_reason_t::TERMINATED) {
+ if (!WIFEXITED(exit_status) || WEXITSTATUS(exit_status) != 0) {
+ did_fail = true;
+ }
+ }
+ else did_fail = (stop_reason != stopped_reason_t::NORMAL);
+
+ cout << (did_fail ? "X" : "-");
+ }
cout << (target == service_state_t::STOPPED ? "}" : " ");
cout << "] " << name;
if (current != service_state_t::STOPPED && service_pid != -1) {
cout << " (pid: " << service_pid << ")";
}
+
+ if (current == service_state_t::STOPPED && stop_reason == stopped_reason_t::TERMINATED) {
+ if (WIFEXITED(exit_status)) {
+ cout << " (exit status: " << WEXITSTATUS(exit_status) << ")";
+ }
+ else if (WIFSIGNALED(exit_status)) {
+ cout << " (signal: " << WSTOPSIG(exit_status) << ")";
+ }
+ }
if (has_console) {
cout << " (has console)";