08c28f2513
kill_bg : -takes the PID of the process to kill -differentiates the sudo case from the non-sudo case
21 lines
296 B
Bash
Executable File
21 lines
296 B
Bash
Executable File
#!/bin/bash
|
|
|
|
function echo_run( )
|
|
{
|
|
echo $@
|
|
$@
|
|
}
|
|
|
|
function kill_bg( )
|
|
{
|
|
PID=$1
|
|
CMD=$(ps -p $PID -o cmd=)
|
|
SUDO=
|
|
TOKILL=$PID
|
|
if [[ ${CMD:0:5} == "sudo " ]] ; then
|
|
SUDO="sudo "
|
|
TOKILL=$(ps --ppid $PID -o pid=)
|
|
fi
|
|
echo_run ${SUDO}kill -9 $TOKILL
|
|
}
|