I use openconnect to connect to my VPN server, one strange thing I've noticed is that if I use kill
or 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.
Thanks.
Log
root@vagrant:~# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=46 time=144 ms
^C
--- 8.8.8.8 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 8.8.8.8
connect: Network is unreachable