Code:
     elif [[ "$1" == '-ksv' ]]  || [[ "$1" == '--killscanvirus' ]]; then
          pkill -INT -x scanvirus
          pkill -INT -x clamscan
          shutdown -c
          printf "scans shutdown\n"

     elif [[ "$1" == '-kls' ]]  || [[ "$1" == '--killlastscan' ]]; then
          pkill -INT -n -x scanvirus
          pkill -INT -n -x clamscan
          shutdown -c
          printf "last scan shutdown\n"
The first function works fine, but it's based on limited understanding of process trees. The scanvirus script has many sub-shells. Control-c works fine for live scans. For background scans, such as:
'scanvirus hupc'
high-speed, update, power-down, copy virus files

scanvirus -ksv works for that. Now, it works if you want do 2+ scans at once. Shutting them down doesn't work right.

I'v looked online for solutions. I need to understand the commands dealing with process trees. How to kill the 'scanvirus' process and all tree branches?

Point me to good tutorial or help me understand it.

Thanks.