]> Pileus Git - mkinit/commitdiff
fixing file descriptor errors, and respawn the listener on /dev/console when stdin...
authorAndy Spencer <andy753421@gmail.com>
Thu, 15 Oct 2009 18:02:59 +0000 (18:02 +0000)
committerAndy Spencer <andy753421@gmail.com>
Thu, 15 Oct 2009 18:02:59 +0000 (18:02 +0000)
init.mk
src/mkinit

diff --git a/init.mk b/init.mk
index aebee30bb5e68209698f643ff4ae7395f3a88e2a..e1956e2ba1d304223c5eb8b7f047c2f18ddbdb93 100644 (file)
--- a/init.mk
+++ b/init.mk
@@ -17,7 +17,7 @@ NPROC=10
 # Runlevels
 user   = alsa keymap polipo spam
 system = at cron hddtemp hostname hwclock i8k sshd swap syslog
-bare   = cpufreq fsclean getty localhost modules mounts uevents utmp
+bare   = cpufreq fsclean getty qingy localhost modules mounts uevents utmp
 
 default:V: user
 
index 05424314e5a4a2c57d72ecb95d500ed623addb04..e9948d1228d26c60f5756fdf14504db5f747bb62 100755 (executable)
@@ -16,6 +16,7 @@ usage: $0 [options] [command]
 
 Options:
   -h,--help    Print usage information
+  -r,--relaod  Prevent spawning listeners when reloading
   -t,--test    Fake all commands
 
 Command:
@@ -116,16 +117,28 @@ fi
 
 if [ ! "$RELOAD" ]; then
        # Fork /dev/initctl listener
+       ( exec 0<&- 1<&- 2<&-
        initctld $INITCTL |
        while read line; do
                echo $line > $CMD
-       done &
+       done &
 
        # Fork console listener
-       while read -e -p "mkinit> " line; do
-               echo $line > $CMD
-               history -s $line
-       done <&0 &
+       # Readline uses stdin,stderr
+       ( exec 1<&-;
+       while true; do
+               while read -e -p "mkinit> " line; do
+                       echo $line > $CMD
+                       history -s $line
+               done
+               [ "$TEST" ] && break
+               exec 0</dev/console 2>/dev/console
+               echo "Respawning on /dev/console.." >&2
+               sleep 1
+       done) <&0 &
+
+       # Close stdin, stderr
+       exec 0<&- 2<&-
 fi
 
 # Kill listeners on exit
@@ -133,7 +146,7 @@ trap "pkill -HUP -P $$ initctld" EXIT
 
 # Main loop
 while true; do
-while line=$(line); do
+while read line; do
        process $line
 done < $CMD
 done