summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/minutils/deps-exe/halt1
-rw-r--r--src/minutils/deps-exe/poweroff1
-rw-r--r--src/minutils/deps-exe/reboot1
-rw-r--r--src/minutils/halt.c7
-rw-r--r--src/minutils/hpr.c21
-rw-r--r--src/minutils/poweroff.c7
-rw-r--r--src/minutils/reboot.c7
-rw-r--r--src/minutils/s6-halt.c16
-rw-r--r--src/minutils/s6-poweroff.c16
-rw-r--r--src/minutils/s6-reboot.c16
10 files changed, 23 insertions, 70 deletions
diff --git a/src/minutils/deps-exe/halt b/src/minutils/deps-exe/halt
deleted file mode 100644
index e7187fe..0000000
--- a/src/minutils/deps-exe/halt
+++ /dev/null
@@ -1 +0,0 @@
--lskarnet
diff --git a/src/minutils/deps-exe/poweroff b/src/minutils/deps-exe/poweroff
deleted file mode 100644
index e7187fe..0000000
--- a/src/minutils/deps-exe/poweroff
+++ /dev/null
@@ -1 +0,0 @@
--lskarnet
diff --git a/src/minutils/deps-exe/reboot b/src/minutils/deps-exe/reboot
deleted file mode 100644
index e7187fe..0000000
--- a/src/minutils/deps-exe/reboot
+++ /dev/null
@@ -1 +0,0 @@
--lskarnet
diff --git a/src/minutils/halt.c b/src/minutils/halt.c
deleted file mode 100644
index 8ef9ef4..0000000
--- a/src/minutils/halt.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/* ISC license. */
-
-#undef PROGNAME
-#define PROGNAME "halt"
-#undef WHATDEFAULT
-#define WHATDEFAULT 1
-#include "hpr.c"
diff --git a/src/minutils/hpr.c b/src/minutils/hpr.c
index d78470e..0e1c27a 100644
--- a/src/minutils/hpr.c
+++ b/src/minutils/hpr.c
@@ -6,7 +6,7 @@
#include <skalibs/strerr2.h>
#include <skalibs/sgetopt.h>
-#define USAGE PROGNAME " [ -h | -p | -r ] [ -f ] [ -w | -d ]"
+#define USAGE PROGNAME " [ -h | -p | -r ] [ -f ]"
int main (int argc, char const *const *argv)
{
@@ -18,7 +18,7 @@ int main (int argc, char const *const *argv)
subgetopt_t l = SUBGETOPT_ZERO ;
for (;;)
{
- register int opt = subgetopt_r(argc, argv, "hprfwd", &l) ;
+ register int opt = subgetopt_r(argc, argv, "hprf", &l) ;
if (opt == -1) break ;
switch (opt)
{
@@ -26,24 +26,19 @@ int main (int argc, char const *const *argv)
case 'p' : what = 2 ; break ;
case 'r' : what = 3 ; break ;
case 'f' : force = 1 ; break ;
- case 'w' : what = 0 ; break ;
- case 'd' : break ;
default : strerr_dieusage(100, USAGE) ;
}
}
argc -= l.ind ; argv += l.ind ;
}
- if (what)
+ if (force)
{
- if (force)
- {
- sync() ;
- reboot(what == 3 ? RB_AUTOBOOT : what == 2 ? RB_POWER_OFF : RB_HALT_SYSTEM) ;
- strerr_diefu1sys(111, "reboot()") ;
- }
- else if (kill(1, what == 3 ? SIGINT : what == 2 ? SIGUSR1 : SIGUSR2) < 0)
- strerr_diefu1sys(111, "signal process 1") ;
+ sync() ;
+ reboot(what == 3 ? RB_AUTOBOOT : what == 2 ? RB_POWER_OFF : RB_HALT_SYSTEM) ;
+ strerr_diefu1sys(111, "reboot()") ;
}
+ else if (kill(1, what == 3 ? SIGINT : what == 2 ? SIGUSR1 : SIGUSR2) < 0)
+ strerr_diefu1sys(111, "signal process 1") ;
return 0 ;
}
diff --git a/src/minutils/poweroff.c b/src/minutils/poweroff.c
deleted file mode 100644
index 2856aac..0000000
--- a/src/minutils/poweroff.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/* ISC license. */
-
-#undef PROGNAME
-#define PROGNAME "poweroff"
-#undef WHATDEFAULT
-#define WHATDEFAULT 2
-#include "hpr.c"
diff --git a/src/minutils/reboot.c b/src/minutils/reboot.c
deleted file mode 100644
index 12480d4..0000000
--- a/src/minutils/reboot.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/* ISC license. */
-
-#undef PROGNAME
-#define PROGNAME "reboot"
-#undef WHATDEFAULT
-#define WHATDEFAULT 3
-#include "hpr.c"
diff --git a/src/minutils/s6-halt.c b/src/minutils/s6-halt.c
index 9613017..d758030 100644
--- a/src/minutils/s6-halt.c
+++ b/src/minutils/s6-halt.c
@@ -1,13 +1,7 @@
/* ISC license. */
-#include <unistd.h>
-#include <sys/reboot.h>
-#include <skalibs/strerr2.h>
-
-int main ()
-{
- PROG = "s6-halt" ;
- sync() ;
- reboot(RB_HALT_SYSTEM) ;
- strerr_diefu1sys(111, "reboot()") ;
-}
+#undef PROGNAME
+#define PROGNAME "s6-halt"
+#undef WHATDEFAULT
+#define WHATDEFAULT 1
+#include "hpr.c"
diff --git a/src/minutils/s6-poweroff.c b/src/minutils/s6-poweroff.c
index b3576b3..f9f7747 100644
--- a/src/minutils/s6-poweroff.c
+++ b/src/minutils/s6-poweroff.c
@@ -1,13 +1,7 @@
/* ISC license. */
-#include <unistd.h>
-#include <sys/reboot.h>
-#include <skalibs/strerr2.h>
-
-int main ()
-{
- PROG = "s6-poweroff" ;
- sync() ;
- reboot(RB_POWER_OFF) ;
- strerr_diefu1sys(111, "reboot()") ;
-}
+#undef PROGNAME
+#define PROGNAME "s6-poweroff"
+#undef WHATDEFAULT
+#define WHATDEFAULT 2
+#include "hpr.c"
diff --git a/src/minutils/s6-reboot.c b/src/minutils/s6-reboot.c
index f006b35..0bf8785 100644
--- a/src/minutils/s6-reboot.c
+++ b/src/minutils/s6-reboot.c
@@ -1,13 +1,7 @@
/* ISC license. */
-#include <unistd.h>
-#include <sys/reboot.h>
-#include <skalibs/strerr2.h>
-
-int main ()
-{
- PROG = "s6-reboot" ;
- sync() ;
- reboot(RB_AUTOBOOT) ;
- strerr_diefu1sys(111, "reboot()") ;
-}
+#undef PROGNAME
+#define PROGNAME "s6-reboot"
+#undef WHATDEFAULT
+#define WHATDEFAULT 3
+#include "hpr.c"