[systemd-devel] Return codes of systemctl (status)

Cecil Westerhof cldwesterhof at gmail.com
Thu Aug 16 17:02:48 UTC 2018


2018-08-16 18:18 GMT+02:00 Dave Reisner <d at falconindy.com>:

> On Thu, Aug 16, 2018 at 01:27:12PM +0200, Cecil Westerhof wrote:
> > The man page of systemctl says:
> >     On success, 0 is returned, a non-zero failure code otherwise.
> >
> > When I do a systemctl status on a service that is not running I get a 3.
> > What other values can be returned and where do I find those?
>
> I believe exit codes are meant to conform to LSB specs:
>
> http://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/iniscrptact.html


That is quite an interesting bit of info. :-D



> In general, I'd suggest not depending on the specific values, but
> instead using a more appropriate verb. For example, if you want to
> know that a service is running, is 'systemctl is-active'.
>

The problem is that I use the commands from Tcl. I use the output, but when
using exec Tcl has 'a problem' with non zero codes. When I ask the status
of a service it can return a 0, 3, or 4. When returning a 3 that is not a
real error and I should inhibit the throw. If it is a 4 (service does not
exist) it is a real error and I should let the throw be fired.

-- 
Cecil Westerhof
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20180816/2ad16653/attachment-0001.html>


More information about the systemd-devel mailing list