I use openconnect to connect to my VPN server, one strange thing I've noticed is that if I use
pkill command to kill a background running openconnect process then the whole Linux network will be unusable, I've to reboot the system to get it running again, but using Ctrl + C killing a foreground openconnect doesn't effect the network useability, I want to make a script to auto restart(kill and re-connect) openconnect at 12 AM every day, so I want to have the ability to terminate it with pkill command.
I wonder the difference between killing it with pkill and killing it with Ctrl + C and how to terminate the process properly in a shell script.
root@vagrant:~# ping 188.8.131.52 PING 184.108.40.206 (220.127.116.11) 56(84) bytes of data. 64 bytes from 18.104.22.168: icmp_seq=1 ttl=46 time=144 ms ^C --- 22.214.171.124 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 138.338/141.269/144.200/2.931 ms root@vagrant:~# ps PID TTY TIME CMD 1397 pts/0 00:00:00 sudo 1398 pts/0 00:00:00 bash 1493 pts/0 00:00:00 openconnect 1495 pts/0 00:00:00 ps root@vagrant:~# pkill openconnect root@vagrant:~# ping 126.96.36.199 connect: Network is unreachable