Additional to the accepted answer - here's ping running in one session, and in another I ran different kill commands.
server~ $ ping google.com
PING google.com (172.217.5.110) 56(84) bytes of data.
64 bytes from google.com(172.217.5.110): icmp_seq=1 ttl=111 time=1.68 ms
64 bytes from google.com(172.217.5.110): icmp_seq=2 ttl=111 time=1.73 ms
Terminated
The above was a SIGTERM, which is signal 15. The exit code was 143.
server ~ $ ping google.com
PING google.com (172.217.5.110) 56(84) bytes of data.
64 bytes from google.com(172.217.5.110): icmp_seq=1 ttl=111 time=1.71 ms
64 bytes from google.com(172.217.5.110): icmp_seq=2 ttl=111 time=1.71 ms
Killed
This was a SIGKILL, which is signal 9. Visually it looks the same, but with a different text, and the exit code is 137 this time.
server~ $ ping google.com
PING google.com (172.217.5.110) 56(84) bytes of data.
64 bytes from google.com(172.217.5.110): icmp_seq=1 ttl=111 time=1.69 ms
64 bytes from google.com(172.217.5.110): icmp_seq=2 ttl=111 time=1.70 ms
**signal sent here**
--- google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 1.697/1.701/1.705/0.004 ms
This was a SIGINT which is signal 2. So functionally the same as a ^C
Curiously the exit code is 0 which to most tests will be a success, as opposed to a failure.
The upshot of this is that ping
does different things for different signals.
You can see a source file for ping at https://gist.github.com/kbaribeau/4495181 which references https://ftp.arl.army.mil/~mike/ping.html as the original.
line
408 signal( SIGINT, finish );
409 signal(SIGALRM, catcher);
457 * C A T C H E R
459 * This routine causes another PING to be transmitted, and then
460 * schedules another SIGALRM for 1 second from now.
See the link for the full code.