summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAndras Korn <korn-debbugs@elan.rulez.org>2012-12-06 16:57:06 +0100
committerGerrit Pape <pape@smarden.org>2024-09-25 23:38:40 +0000
commitb958506f7c1d51cea86a29b829dab6accbdc5c92 (patch)
treea4914793eb983430d9ecc420a94e7a377cbb3e5d /src
parent58c4dce8cd92034f5c874e315bb291032355d51a (diff)
downloadrunit-b958506f7c1d51cea86a29b829dab6accbdc5c92.tar.gz
runit-b958506f7c1d51cea86a29b829dab6accbdc5c92.tar.xz
runit-b958506f7c1d51cea86a29b829dab6accbdc5c92.zip
support /etc/runit/nosync file to make sync on shutdown/reboot optional
https://bugs.debian.org/695281
Diffstat (limited to 'src')
-rw-r--r--src/runit.c15
-rw-r--r--src/runit.h1
2 files changed, 11 insertions, 5 deletions
diff --git a/src/runit.c b/src/runit.c
index 25da3b8..c6c9cea 100644
--- a/src/runit.c
+++ b/src/runit.c
@@ -41,6 +41,11 @@ void sig_int_handler (void) {
 }
 void sig_child_handler (void) { write(selfpipe[1], "", 1); }
 
+void sync_if_needed() {
+  struct stat s;
+  if (stat(NOSYNC, &s) == -1) sync();
+}
+
 int main (int argc, const char * const *argv, char * const *envp) {
   const char * prog[2];
   int pid, pid2;
@@ -305,28 +310,28 @@ int main (int argc, const char * const *argv, char * const *envp) {
   case -1:
   if ((stat(REBOOT, &s) != -1) && (s.st_mode & S_IXUSR)) {
     strerr_warn2(INFO, "system reboot.", 0);
-    sync();
+    sync_if_needed();
     reboot_system(RB_AUTOBOOT);
   }
   else {
 #ifdef RB_POWER_OFF
     strerr_warn2(INFO, "power off...", 0);
-    sync();
+    sync_if_needed();
     reboot_system(RB_POWER_OFF);
     sleep(2);
 #endif
 #ifdef RB_HALT_SYSTEM
     strerr_warn2(INFO, "system halt.", 0);
-    sync();
+    sync_if_needed();
     reboot_system(RB_HALT_SYSTEM);
 #else
 #ifdef RB_HALT
     strerr_warn2(INFO, "system halt.", 0);
-    sync();
+    sync_if_needed();
     reboot_system(RB_HALT);
 #else
     strerr_warn2(INFO, "system reboot.", 0);
-    sync();
+    sync_if_needed();
     reboot_system(RB_AUTOBOOT);
 #endif
 #endif
diff --git a/src/runit.h b/src/runit.h
index ba98386..3d52001 100644
--- a/src/runit.h
+++ b/src/runit.h
@@ -1,4 +1,5 @@
 #define RUNIT "/sbin/runit"
 #define STOPIT "/etc/runit/stopit"
 #define REBOOT "/etc/runit/reboot"
+#define NOSYNC "/etc/runit/nosync"
 #define CTRLALTDEL "/etc/runit/ctrlaltdel"