diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2019-03-02 09:41:24 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2019-03-02 09:41:24 +0000 |
commit | 23fba266a9454ee6ca095b7f6eccf523f6526607 (patch) | |
tree | 7350fdaba49b1529a13d50f6396aea35f340954d /src/state/s6-linux-init-telinit.c | |
parent | 54d0dc0990f13a86680fa55c623f0570853749ac (diff) | |
download | s6-linux-init-23fba266a9454ee6ca095b7f6eccf523f6526607.tar.xz |
Save pending changes in 1.0.0.0 branch
Diffstat (limited to 'src/state/s6-linux-init-telinit.c')
-rw-r--r-- | src/state/s6-linux-init-telinit.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/state/s6-linux-init-telinit.c b/src/state/s6-linux-init-telinit.c new file mode 100644 index 0000000..856e78b --- /dev/null +++ b/src/state/s6-linux-init-telinit.c @@ -0,0 +1,42 @@ +/* ISC license. */ + +#include <skalibs/sgetopt.h> +#include <skalibs/types.h> +#include <skalibs/strerr2.h> + +#include "defaults.h" +#include "initctl.h" +#include "hpr.h" + +#define USAGE "s6-linux-init-telinit runlevel" +#define dieusage() strerr_dieusage(100, USAGE) + +int main (int argc, char const *const *argv, char const *const *envp) +{ + PROG = "s6-linux-init-telinit" ; + { + subgetopt_t l = SUBGETOPT_ZERO ; + for (;;) + { + int opt = subgetopt_r(argc, argv, "rc:p:s:m:d:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case 'r' : + case 'c' : + case 'p' : + case 's' : + case 'm' : + case 'd' : break ; + default : dieusage() ; + } + } + argc -= l.ind ; argv += l.ind ; + } + + if (!argc) dieusage() ; + if (!argv[0][0] || argv[0][1]) dieusage() ; + if (argv[0][0] != 'S' && (argv[0][0] < '0' || argv[0][0] > '6')) dieusage() ; + if (!hpr_send(argv[0], 1)) strerr_diefu2sys(111, "write to ", INITCTL) ; + return 0 ; +} |