Bug #1989 Control-C aborts client
Submitted: 1 Dec 2003 12:51 Modified: 4 May 2006 18:32
Reporter: [ name withheld ]
Status: Closed
Category:Client Severity:S4 (Feature request)
Version: OS:Linux (Linux)
Assigned to: Jim Winstead Target Version:
Triage: D5 (Feature request)

[1 Dec 2003 12:51] [ name withheld ]
Description:
Pressing Ctrl-C in the Linux command line client aborts it.  I find this very annoying. 
Ctrl-C should imho only cancel the half-typed sql command and return to a new prompt.  At
this point, Ctrl-D might stop the client.  Like in any decent Shell.

How to repeat:
Like I said.
[1 Dec 2003 14:36] Dean Ellis
I am changing this to a feature request.

Thank you for your suggestion.
[1 Sep 2004 20:00] Shawn Green
I would like the option of using ctrl-c to abort a long query from the client without
causing the client to exit.  I don't know how many times I started something, realized my
mistake and wanted a "stop query" feature. I have begun running two sessions at once: one
for my live queries and one I can use to KILL any long-running queries I started in the
first session. 

Also, If I request to stop a query from the same client that initiated it, I also should
not need to reconnect to the server (I shouldn't lose my connection, only abort the
statement). It would be nice that while acting as an administrator I could cancel a
statement from another process without breaking that processes connection. They would
just get an error back like "Statement aborted by administrator" or "Statement aborted by
user@hostname" but keep their connection.
[28 Nov 2005 8:47] Valeriy Kravchuk
Thank you for several feature requests in one. I agree, that Ctrl-C will be a good way to
stop/break current statement execution. But for it to be possible  I also agree, that
there should be some way for the user with appropriate privileges (administrator) to stop
(kill) other users threads in client. We already have mysql_kill() in C API
(http://dev.mysql.com/doc/refman/5.0/en/mysql-kill.html).
[28 Nov 2005 11:15] Valeriy Kravchuk
Oh, sorry, there is a KILL command already.
http://dev.mysql.com/doc/refman/5.0/en/kill.html. So, what is needed is just perform KILL
QUERY for current thread when Ctrl+C is pressed.
[3 May 2006 21:04] Jim Winstead
Fixed in 5.1.10. When Ctrl-C is used, the client will first try to kill the query. If it
cannot do so, or Ctrl-C is pressed again before it is done, the client will exit as
before.
[4 May 2006 18:32] Paul DuBois
Noted in 5.1.10 changelog.
[12 Jan 2008 5:11] Karim Nassar
This bug should not be closed.

The original bug was that ctrl-c exits the mysql shell. I would like to extend the
feature request to make this a configurable option. Many shell gurus hit ctrl-c by force
of habit. They (I being one of them) would LOVE to have an option to make the mysql shell
NOT exit when force of habit takes control. For an example of the desired behavior, open a
bash shell, type 'rm -rf foo' hit ctrl-c.