You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
3.1 KiB
82 lines
3.1 KiB
From 2eb2ddac8eaa258dd1ac0b2d4c1aefef9b66a989 Mon Sep 17 00:00:00 2001 |
|
From: Susant Sahani <ssahani@users.noreply.github.com> |
|
Date: Mon, 30 May 2016 20:23:15 +0530 |
|
Subject: [PATCH] systemctl: return diffrent error code if service exist or not |
|
(#3385) |
|
MIME-Version: 1.0 |
|
Content-Type: text/plain; charset=UTF-8 |
|
Content-Transfer-Encoding: 8bit |
|
|
|
Before: |
|
[sus@maximus bz-1256858]$ systemctl status rsyslog.service;echo $? |
|
● rsyslog.service - System Logging Service |
|
Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor |
|
preset: enabled) |
|
Drop-In: /etc/systemd/system/rsyslog.service.d |
|
└─50-CPUShares.conf |
|
Active: inactive (dead) since Mon 2016-05-30 11:54:25 IST; 2h 26min ago |
|
Docs: man:rsyslogd(8) |
|
http://www.rsyslog.com/doc/ |
|
Process: 1159 ExecStart=/usr/sbin/rsyslogd -n $SYSLOGD_OPTIONS (code=exited, |
|
status=0/SUCCESS) |
|
Main PID: 1159 (code=exited, status=0/SUCCESS) |
|
|
|
May 30 11:07:50 maximus systemd[1]: Starting System Logging Service... |
|
May 30 11:07:50 maximus systemd[1]: Started System Logging Service. |
|
May 30 11:54:25 maximus systemd[1]: Stopping System Logging Service... |
|
May 30 11:54:25 maximus systemd[1]: Stopped System Logging Service. |
|
3 |
|
[sus@maximus bz-1256858]$ systemctl status hello.service;echo $? |
|
● hello.service |
|
Loaded: not-found (Reason: No such file or directory) |
|
Active: inactive (dead) |
|
3 |
|
|
|
After: |
|
$ ./systemctl status hello.service;echo $? |
|
Failed to dump process list, ignoring: Access denied |
|
● hello.service |
|
Loaded: not-found (Reason: No such file or directory) |
|
Active: inactive (dead) |
|
4 |
|
[sus@maximus bz-1256858]$ ./systemctl status rsyslog.service;echo $? |
|
Failed to dump process list, ignoring: Access denied |
|
● rsyslog.service - System Logging Service |
|
Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor |
|
preset: enabled) |
|
Drop-In: /etc/systemd/system/rsyslog.service.d |
|
└─50-CPUShares.conf |
|
Active: inactive (dead) since Mon 2016-05-30 11:54:25 IST; 2h 24min ago |
|
Docs: man:rsyslogd(8) |
|
http://www.rsyslog.com/doc/ |
|
Process: 1159 ExecStart=/usr/sbin/rsyslogd -n $SYSLOGD_OPTIONS (code=exited, |
|
status=0/SUCCESS) |
|
Main PID: 1159 (code=exited, status=0/SUCCESS) |
|
|
|
May 30 11:07:50 maximus systemd[1]: Starting System Logging Service... |
|
May 30 11:07:50 maximus systemd[1]: Started System Logging Service. |
|
May 30 11:54:25 maximus systemd[1]: Stopping System Logging Service... |
|
May 30 11:54:25 maximus systemd[1]: Stopped System Logging Service. |
|
3 |
|
|
|
Fixes: 1092 |
|
|
|
(cherry picked from commit ca473d572f0d2d8f547ff787ae67afd489a3f15e) |
|
Resolves: #1047466 |
|
--- |
|
src/systemctl/systemctl.c | 2 ++ |
|
1 file changed, 2 insertions(+) |
|
|
|
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c |
|
index 95ddf3be76..6079d60dbf 100644 |
|
--- a/src/systemctl/systemctl.c |
|
+++ b/src/systemctl/systemctl.c |
|
@@ -4295,6 +4295,8 @@ static int show_one( |
|
*/ |
|
if (info.pid_file && access(info.pid_file, F_OK) == 0) |
|
r = 1; |
|
+ else if (streq_ptr(info.load_state, "not-found") && streq_ptr(info.active_state, "inactive")) |
|
+ r = 4; |
|
else |
|
r = 3; |
|
}
|
|
|