]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bitbake: toaster: server shutdown on terminal exit
authorAlexandru DAMIAN <alexandru.damian@intel.com>
Fri, 1 Nov 2013 15:58:33 +0000 (15:58 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 4 Nov 2013 09:36:22 +0000 (09:36 +0000)
If the terminal where the server was started is closed,
the bitbake server should shutdown. Currently the system
is left in hanging state.

This patch uses "trap" command to make sure the servers
are closed on terminal exit.

[YOCTO #5376]

(Bitbake rev: 5f8b97010f7b465753b6ff6275d18426006ee14b)

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/bin/toaster

index 16de52b1154414af34b17bd8c79beae32a4a2238..cc631f6f569d34c4dbd2866c03c0f7ade3927691 100755 (executable)
@@ -49,6 +49,19 @@ function webserverStartAll()
         return $retval
 }
 
+# define the stop command
+function stop_system()
+{
+    if [ -f ${BUILDDIR}/.toasterui.pid ]; then
+        kill $(< ${BUILDDIR}/.toasterui.pid )
+        rm ${BUILDDIR}/.toasterui.pid
+    fi
+    BBSERVER=localhost:8200 bitbake -m
+    unset BBSERVER
+    webserverKillAll
+    # force stop any misbehaving bitbake server
+    lsof bitbake.lock | awk '{print $2}' | grep "[0-9]\+" | xargs -n1 -r kill
+}
 
 # We make sure we're running in the current shell and in a good environment
 
@@ -116,6 +129,9 @@ and
 fi
 
 
+
+
+
 # Execute the commands
 
 case $CMD in
@@ -127,17 +143,12 @@ case $CMD in
         if [ $NOTOASTERUI == 0 ]; then        # we start the TOASTERUI only if not inhibited
             bitbake --observe-only -u toasterui >${BUILDDIR}/toaster_ui.log 2>&1 & echo $! >${BUILDDIR}/.toasterui.pid
         fi
+        # stop system on terminal exit
+        trap stop_system SIGHUP
     ;;
     stop )
-        if [ -f ${BUILDDIR}/.toasterui.pid ]; then
-            kill $(< ${BUILDDIR}/.toasterui.pid )
-            rm ${BUILDDIR}/.toasterui.pid
-        fi
-        bitbake -m
-        unset BBSERVER
-        webserverKillAll
-        # force stop any misbehaving bitbake server
-        lsof bitbake.lock | awk '{print $2}' | grep "[0-9]\+" | xargs -n1 -r kill
+        stop_system
+        trap '' SIGHUP
     ;;
 esac