diff options
author | José Bollo <jose.bollo@iot.bzh> | 2020-05-19 11:22:26 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2020-05-19 14:11:44 +0200 |
commit | f8f2338aba84394e132fff55b6ebdef7d884292b (patch) | |
tree | dda988169851b84525431e904f473fc515868abb /src/utils-systemd.h | |
parent | e7ac328451fa3b3edfbd3658a2365b75d41c0698 (diff) |
Improve use of systemd's states
A better handling of systemd state is need to treat
correctly transient states. That change includes:
- Management of states with numeric identifiers
instead of names
- Handling of the state "inactive" as a stable
state. Most of previous seen problems were coming
from that miss.
- Returning no error but also no info on the process
if it falled to "inactive" meaning that it stopped
quickly.
Bug-AGL: SPEC-3323
Change-Id: Ibf35eb6257c5583596d675cad0bec2869f5fd5f7
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/utils-systemd.h')
-rw-r--r-- | src/utils-systemd.h | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/utils-systemd.h b/src/utils-systemd.h index cf95097..3bddfd6 100644 --- a/src/utils-systemd.h +++ b/src/utils-systemd.h @@ -18,12 +18,15 @@ #pragma once -extern const char SysD_State_Inactive[]; -extern const char SysD_State_Activating[]; -extern const char SysD_State_Active[]; -extern const char SysD_State_Deactivating[]; -extern const char SysD_State_Reloading[]; -extern const char SysD_State_Failed[]; +enum SysD_State { + SysD_State_INVALID, + SysD_State_Inactive, + SysD_State_Activating, + SysD_State_Active, + SysD_State_Deactivating, + SysD_State_Reloading, + SysD_State_Failed +}; struct sd_bus; extern int systemd_get_bus(int isuser, struct sd_bus **ret); @@ -48,8 +51,10 @@ extern int systemd_unit_stop_name(int isuser, const char *name); extern int systemd_unit_stop_pid(int isuser, unsigned pid); extern int systemd_unit_pid_of_dpath(int isuser, const char *dpath); -extern const char *systemd_unit_state_of_dpath(int isuser, const char *dpath); +extern enum SysD_State systemd_unit_state_of_dpath(int isuser, const char *dpath); extern int systemd_unit_list(int isuser, int (*callback)(void *closure, const char *name, const char *path, int isuser), void *closure); extern int systemd_unit_list_all(int (*callback)(void *closure, const char *name, const char *path, int isuser), void *closure); +extern const char *systemd_state_name(enum SysD_State state); + |