hostapd: let start-stop-daemon create PID and background process

The current script cannot launch the hostapd twice (for dual HostAP mode)
because start-stop-daemon finds an already existing PID for hostapd after
running the first instance.

The solution is:
 - Do not launch the hostapd in background (so that it does not fork the
   process, which assigns a different PID)
 - Use -b option of start-stop-daemon so that it launches the daemon in
   the background.
 - Let start-stop-daemon create the PID (since the hostapd will not fork
   now this PID will match the hostapd process, allowing to kill it later)

This solution also hides the hostapd log messages that appeared before.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>

https://jira.digi.com/browse/DEL-4045
This commit is contained in:
Hector Palacios 2017-04-07 11:26:58 +02:00
parent 80e5756770
commit 505eb19aa4
1 changed files with 2 additions and 2 deletions

View File

@ -3,7 +3,7 @@ DAEMON=/usr/sbin/hostapd
NAME=hostapd NAME=hostapd
DESC="HOSTAP Daemon" DESC="HOSTAP Daemon"
PIDFILE="/var/run/hostapd.${IFACE}.pid" PIDFILE="/var/run/hostapd.${IFACE}.pid"
ARGS="/etc/hostapd_${IFACE}.conf -B -P ${PIDFILE}" ARGS="/etc/hostapd_${IFACE}.conf"
test -f $DAEMON || exit 0 test -f $DAEMON || exit 0
@ -29,7 +29,7 @@ delay_stop() {
case "$1" in case "$1" in
start) start)
echo -n "Starting $DESC: " echo -n "Starting $DESC: "
start-stop-daemon -S -x $DAEMON -- $ARGS start-stop-daemon -S -x $DAEMON -m -p ${PIDFILE} -b -- $ARGS
echo "$NAME." echo "$NAME."
;; ;;
stop) stop)