shinit

basic init daemon in POSIX sh
git clone git://git.ckyln.com/~cem/shinit.git
Log | Files | Refs | README | LICENSE

shinit (632B)


      1 #!/bin/sh
      2 
      3 # Exit with status 1 if pid is not 1
      4 [ $$ -eq 1 ] || exit 1
      5 
      6 # Run the boot script
      7 /lib/init/rc.boot
      8 
      9 # Add signal traps for poweroff and reboot
     10 trap '/lib/init/rc.shutdown poweroff' USR1
     11 trap '/lib/init/rc.shutdown reboot'   INT
     12 
     13 # Sleep for a day. As sleep is not a builtin for every
     14 # shell, we don't want to keep spawning processes, hence
     15 # the long sleep time.
     16 #
     17 # We also don't want to run 'while :; do :; done' as
     18 # it would lead to high cpu usage.
     19 #
     20 # Since we want to trap signals, We fork and wait for the
     21 # sleep. If sleep is not forked, signals will not be acted
     22 # upon.
     23 while :; do sleep 86400 & wait ; done