Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* Ignore SIGHUP and write errors on stderr to ensure that

  switch-to-configuration runs to completion (e.g. if the tty we're on
  got killed).

svn path=/nixos/trunk/; revision=33382
  • Loading branch information...
commit 43b5ced96c230a92cdeddbddd364e1c053dd5268 1 parent 1949a85
Eelco Dolstra edolstra authored
Showing with 12 additions and 4 deletions.
  1. +12 −4 modules/system/activation/switch-to-configuration.sh
16 modules/system/activation/switch-to-configuration.sh
View
@@ -76,6 +76,10 @@ EOF
exit 1
fi
+# Ignore SIGHUP so that we're not killed if we're running on (say)
+# virtual console 1 and we restart the "tty1" job.
+trap "" SIGHUP
+
jobsDir=$(readlink -f @out@/etc/init)
# Stop all currently running jobs that are not in the new Upstart
@@ -113,6 +117,10 @@ start_() {
fi
}
+log() {
+ echo "$@" >&2 || true
+}
+
# Restart all running jobs that have changed. (Here "running" means
# all jobs that don't have a "stop" goal.) We use the symlinks in
# /var/run/upstart-jobs (created by each job's pre-start script) to
@@ -122,10 +130,10 @@ for job in @jobs@; do
if ! [[ "$status" =~ start/ ]]; then continue; fi
if [ "$(readlink -f "$jobsDir/$job.conf")" = "$(readlink -f "/var/run/upstart-jobs/$job")" ]; then continue; fi
if [ -n "${noRestartIfChanged[$job]}" ]; then
- echo "not restarting changed service ‘$job"
+ log "not restarting changed service ‘$job"
continue
fi
- echo "restarting changed service ‘$job’..."
+ log "restarting changed service ‘$job’..."
# Note: can't use "restart" here, since that only restarts the
# job's main process.
stop --quiet "$job" || true
@@ -147,11 +155,11 @@ for job in @jobs@; do
"$(readlink -f "$jobsDir/$job.conf")" = "$(readlink -f "/var/run/upstart-jobs/$job")" ];
then continue; fi
if [ -n "${noRestartIfChanged[$job]}" ]; then continue; fi
- echo "starting task ‘$job’..."
+ log "starting task ‘$job’..."
start --quiet "$job" || true
else
if ! grep -q "^start on" "$jobsDir/$job.conf"; then continue; fi
- echo "starting service ‘$job’..."
+ log "starting service ‘$job’..."
start_ "$job" || true
fi
Please sign in to comment.
Something went wrong with that request. Please try again.