From 39fb8b5ed810df3b306373607183e8d4976d7311 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Thu, 15 Oct 2009 18:02:59 +0000 Subject: [PATCH] fixing file descriptor errors, and respawn the listener on /dev/console when stdin closes --- init.mk | 2 +- src/mkinit | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/init.mk b/init.mk index aebee30..e1956e2 100644 --- 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 diff --git a/src/mkinit b/src/mkinit index 0542431..e9948d1 100755 --- a/src/mkinit +++ b/src/mkinit @@ -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 + 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 -- 2.43.2