diff options
author | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-03-24 22:31:05 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-03-24 22:50:28 +0100 |
commit | 1b3b98135eefe7cf03a379be1d5ebf13369dcfa5 (patch) | |
tree | b9dee75d538f40557bcbd72b31f7fae30c8012ac /lib/include/service.h | |
parent | bb9ff43ea25dd80d5fb0f26addcef4e7b06c7990 (diff) |
Add license headers and comments to source
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'lib/include/service.h')
-rw-r--r-- | lib/include/service.h | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/lib/include/service.h b/lib/include/service.h index eb92d85..6808bdd 100644 --- a/lib/include/service.h +++ b/lib/include/service.h @@ -1,19 +1,45 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * Copyright (C) 2018 - David Oberhollenzer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ #ifndef SERVICE_H #define SERVICE_H #include <sys/types.h> enum { + /* + Start the service in the background and continue with + other services. The service will eventually terminate. + */ SVC_ONCE = 0, - SVC_WAIT, + SVC_WAIT, /* run service and wait until it finishes */ + + /* + Similar to SVC_ONCE, but restart the service when + it terminates. + */ SVC_RESPAWN, }; enum { - TGT_BOOT = 0, - TGT_SHUTDOWN, - TGT_REBOOT, - TGT_CAD, + TGT_BOOT = 0, /* run service when the system boots */ + TGT_SHUTDOWN, /* run service when at system shut down */ + TGT_REBOOT, /* run service when during system reboot */ + TGT_CAD, /* run service when CTRL+ALT+DEL is pressed */ TGT_MAX }; @@ -27,9 +53,9 @@ typedef struct service_t { size_t num_exec; /* number of command lines */ char *ctty; /* controlling tty or log file */ - char **before; + char **before; /* services that must be executed later */ size_t num_before; - char **after; + char **after; /* services that must be executed first */ size_t num_after; pid_t pid; @@ -49,6 +75,13 @@ service_t *rdsrv(int dirfd, const char *filename); void delsrv(service_t *srv); +/* + Rebuild a service list by scanning a directory and parsing all + service descriptions. + + Returns 0 on success, -1 on failure. The function takes care of + printing error messages on failure. +*/ int srvscan(const char *directory, service_list_t *list); void del_srv_list(service_list_t *list); |