#!/bin/ash
#
# acp_exp_shell:
# This script starts acp_tty2pty if it is not running already and
# then calls exp_shell binary.
# On exit from exp_shell it terminates acp_tty2pty
#
# Usage:
# acp_exp_shell
#

export PATH=$PATH:/usr/local/acp/bin
if [ -z "`pidof acp_tty2pty`" ] ; then
    echo "Starting acp_tty2pty process"
    acp_tty2pty
else
    echo "acp_tty2pty process is already running"
fi
exp_shell
if [ -z "`pidof exp_shell`" ]; then
    pidof exp_shell
    pid=$(pidof acp_tty2pty)
    if [ -n "$pid" ] ; then
        echo "Terminating acp_tty2pty process with pid: $pid"
        kill -SIGINT $pid
    fi
fi
