summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--doc/runit.8.html2
-rw-r--r--man/runit.85
-rw-r--r--src/runit.c15
-rw-r--r--src/runit.h1
4 files changed, 18 insertions, 5 deletions
diff --git a/doc/runit.8.html b/doc/runit.8.html
index 6c46b39..3cc8287 100644
--- a/doc/runit.8.html
+++ b/doc/runit.8.html
@@ -34,6 +34,8 @@ stage 2 if it is running, and runs <i>/etc/runit/3</i>. The systems tasks to shu
 and possibly halt or reboot the system are done here. If stage 3 returns,
 <b>runit</b> checks if the file <i>/etc/runit/reboot</i> exists and has the execute by
 owner permission set. If so, the system is rebooted, it&rsquo;s halted otherwise.
+If <i>/etc/runit/nosync</i> exists, <b>runit</b> doesn&rsquo;t invoke
+sync(). This is useful in vservers.
 
 <h2><a name='sect6'>Ctrl-alt-del</a></h2>
 If <b>runit</b> receives the ctrl-alt-del keyboard request and the file
diff --git a/man/runit.8 b/man/runit.8
index a53cf6e..faf789b 100644
--- a/man/runit.8
+++ b/man/runit.8
@@ -48,6 +48,11 @@ checks if the file
 .I /etc/runit/reboot
 exists and has the execute by owner permission set.
 If so, the system is rebooted, it's halted otherwise.
+If
+.I /etc/runit/nosync
+exists,
+.B runit
+doesn't invoke sync(). This is useful in vservers.
 .SH CTRL-ALT-DEL
 If
 .B runit
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"