Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • 2
    @AmirrezaRiahi The default action of the SIGINT signal is to kill the process. But the process can override this default. Commented Nov 9, 2020 at 6:12
  • 1
    @Barmar, same with SIGTERM Commented Nov 9, 2020 at 8:43
  • 1
    @AmirrezaRiahi if by chance your problem was not being to break out of ping when called in a bash loop, you can use awk as a wrapper: xawk(){ awk "BEGIN{system(\"$*\")}"; }; ...; while xawk ping www.google.com; do :; done => will promptly die after the first Control-C, no need to keep it pressed ;-) (I've seen this in some answer here -- but I'm not able to find it now). Commented Nov 9, 2020 at 11:11
  • 1
    @user414777 Actually ping does obey WCE. To it, Ctrl-C is a request to perform a normal exit of the otherwise infinite loop, thus it exits with a normal status, not a signal. This causes bash to correctly continue running additional commands in a script. (Not that you would typically run ping this way in a script anyway.) Commented Nov 9, 2020 at 23:22
  • 1
    I disagree that most users should expect that. It's no different from running nano or another interactive editor and using whatever command that provides to perform a normal exit. It just so happens that in the case of ping that it uses Ctrl+C to request a normal exit, that's all. Commented Nov 10, 2020 at 22:53