X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=util.c;h=f7d538aaacf87496367661ba3822bc2f44cb6070;hb=f58eedd538b3a138814a54b94b0c2c89ef727d82;hp=95791f941d86975dbff743b26e01eda335559a9b;hpb=ca139f94c8de427616f54ab38262a47c4a636ffd;p=elogind.git diff --git a/util.c b/util.c index 95791f941..f7d538aaa 100644 --- a/util.c +++ b/util.c @@ -1910,6 +1910,33 @@ int make_stdio(int fd) { return 0; } +bool is_clean_exit(int code, int status) { + + if (code == CLD_EXITED) + return status == 0; + + /* If a daemon does not implement handlers for some of the + * signals that's not considered an unclean shutdown */ + if (code == CLD_KILLED) + return + status == SIGHUP || + status == SIGINT || + status == SIGTERM || + status == SIGPIPE; + + return false; +} + +bool is_device_path(const char *path) { + + /* Returns true on paths that refer to a device, either in + * sysfs or in /dev */ + + return + path_startswith(path, "/dev/") || + path_startswith(path, "/sys/"); +} + static const char *const ioprio_class_table[] = { [IOPRIO_CLASS_NONE] = "none", [IOPRIO_CLASS_RT] = "realtime",