That is interesting behavior with that while loop using the ping command. I was able to stop it indirectly which is good enough I suppose.
First, use control-z to get back to the shell. That will suspend the job and put it in the background. But doesn't kill it. After that, you can use 'kill %1' to kill the job.
First I tried control-C which only killed the ping program but not the loop. Then I used control-Z which forced the job to be suspended in the background. 'kill %1' means to kill background job 1 in your shell.
First, use control-z to get back to the shell. That will suspend the job and put it in the background. But doesn't kill it. After that, you can use 'kill %1' to kill the job.
Code:
mbp-wl:~$ while true; do ping -c 3 yahoo.com; done
PING yahoo.com (98.139.183.24): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
^C
--- yahoo.com ping statistics ---
3 packets transmitted, 0 packets received, 100.0% packet loss
PING yahoo.com (98.139.183.24): 56 data bytes
Request timeout for icmp_seq 0
^Z
[1]+ Stopped ping -c 3 yahoo.com
mbp-wl:~$ kill %1
[1]+ Stopped ping -c 3 yahoo.com
mbp-wl:~$
[1]+ Terminated: 15 ping -c 3 yahoo.com
mbp-wl:~$
First I tried control-C which only killed the ping program but not the loop. Then I used control-Z which forced the job to be suspended in the background. 'kill %1' means to kill background job 1 in your shell.