]> Shamusworld >> Repos - init-ng/commitdiff
More cleanup; thanks to WilliamH for the patch.
authorShamus Hammons <jlhamm@acm.org>
Wed, 10 Dec 2014 21:01:53 +0000 (15:01 -0600)
committerShamus Hammons <jlhamm@acm.org>
Wed, 10 Dec 2014 21:01:53 +0000 (15:01 -0600)
init

diff --git a/init b/init
index dc0f2ac18d55e6c268aa8b835c2c6b497c582418..11b05cafc64ebb332226afb966bed1ce91bb60fa 100755 (executable)
--- a/init
+++ b/init
@@ -3,25 +3,26 @@
 require 'socket'
 
 
-def do_cmd(*cmd)
-  ctl = UNIXSocket.open('/run/initctl')
-  ctl.puts(cmd.join(' '))
-  puts(ctl.readline.chomp)
-  exit
-end
-
-
 # These are hashes
-
 $daemons = {}
 $daemonCmds = {}
 
 # Needed to prevent respawning during a reboot...
-
 $shuttingDown = false
 
-# Here we do some process monitoring...
 
+def launch(id, cmd)
+  puts('Starting %s...' % id)
+  pid = fork do
+    Process.setsid()
+    exec(*cmd)
+  end
+  $daemons[id] = pid
+  $daemonCmds[id] = cmd
+end
+
+
+# Here we do some process monitoring...
 Signal.trap(:SIGCHLD) do
   loop do
     begin
@@ -47,17 +48,6 @@ Signal.trap(:SIGCHLD) do
 end
 
 
-def launch(id, cmd)
-  puts('Starting %s...' % id)
-  pid = fork do
-    Process.setsid()
-    exec(*cmd)
-  end
-  $daemons[id] = pid
-  $daemonCmds[id] = cmd
-end
-
-
 def init
   puts('*** init-ng v1.0.0 starting...')
 
@@ -84,8 +74,15 @@ def shutdown
 end
 
 
-# This shows the one of the hazards of coding this in Ruby...
+def do_cmd(*cmd)
+  ctl = UNIXSocket.open('/run/initctl')
+  ctl.puts(cmd.join(' '))
+  puts(ctl.readline.chomp)
+  exit
+end
 
+
+# This shows the one of the hazards of coding this in Ruby...
 def sys_reboot(cmd)
   # LINUX_REBOOT_CMD_POWER_OFF == 0x4321FEDC
   # LINUX_REBOOT_CMD_RESTART   == 0x01234567