#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin
+PGREP=/usr/bin/pgrep
#
# Script for stopping Bluetooth stack
/usr/etc/bluetooth/bt-dev-end.sh
# Kill BlueZ bluetooth stack
-killall bluetooth
-killall obexd obex-client
-killall bluetooth-share
-killall bluetooth-pb-agent
-killall bluetooth-map-agent
-killall bluetooth-hfp-agent
-killall bluetoothd
+
+if ($PGREP bluetooth); then
+ BLUETOOTH_PID=$($PGREP bluetooth)
+ kill $BLUETOOTH_PID
+fi
+
+if ($PGREP obexd); then
+ OBEXD_PID=$($PGREP obexd)
+ kill $OBEXD_PID
+fi
+
+if ($PGREP obexd-client); then
+ OBEXDCLIENT_PID=$($PGREP obexd-client)
+ kill $OBEXDCLIENT_PID
+fi
+
+if ($PGREP bluetooth-share); then
+ BTSHARE_PID=$($PGREP bluetooth-share)
+ kill $BTSHARE_PID
+fi
+
+if ($PGREP bluetooth-pb-agent); then
+ BTPB_AGENT_PID=$($PGREP bluetooth-pb-agent)
+ kill $BTPB_AGENT_PID
+fi
+
+if ($PGREP bluetooth-map-agent); then
+ BTMAP_AGENT_PID=$($PGREP bluetooth-map-agent)
+ kill $BTMAP_AGENT_PID
+fi
+
+if ($PGREP bluetooth-hfp-agent); then
+ BTHFP_AGENT_PID=$($PGREP bluetooth-hfp-agent)
+ kill $BTHFP_AGENT_PID
+fi
+
+if ($PGREP bluetoothd); then
+ BLUETOOTHD_PID=$($PGREP bluetoothd)
+ kill $BLUETOOTHD_PID
+fi
+
# result
exit 0