Ctrl-C (Break key) for Mac?

Discussion in 'Mac Basics and Help' started by Decollete, May 17, 2010.

  1. Decollete macrumors newbie

    May 17, 2010
    Hello. I just recently started using a Mac and I have a simple question I couldn't find over the net.

    How do I send the break key in Mac? For example in terminal, if I typed a long line but want to abort it, I used press Ctrl-C to cancel it in a different OS. Or if there is a console application, I press Ctrl-C to force the application to close.

    I checked websites which told me to use the following:
    command key + C - doesn't work
    (I tried shift + command key + C, it also does not work)
    alt + F3 (I pressed shift, option [for alt] and f3) - all my windows spread apart from each other
    option + F3 - Expose & Spaces configuration window appears

    Please help if you know the key. Thanks!
  2. forcefieldkid macrumors 6502

    Jan 20, 2010
    Cmnd+Q quits an application.
    cmnd+alt+escape brings up the force quit menu where you can select the application and quit it.
  3. sammich macrumors 601


    Sep 26, 2006
    The SIGKILL combo is control-c, in all the shells I've used.
  4. miles01110 macrumors Core


    Jul 24, 2006
    The Ivory Tower (I'm not coming down)
    Control-C does exactly what you describe in the standard OS X shell.
  5. Decollete thread starter macrumors newbie

    May 17, 2010
    Thanks for all the replies.
    Unfortunately, it does not behave the same way for me.

    Mac OS X
    Version 10.6.3

    Version 2.1.1 (273)

    Name: <my name>’s Keyboard
    Address: 7c-6d-62-3f-5b-ff
    Type: Keyboard
    Firmware Version: 0x50
    Services: Apple Wireless Keyboard
    Paired: Yes
    Favorite: No
    Connected: Yes
    Manufacturer: Apple (0x3, 0x31c)
    Vendor ID: 0x5ac
    Product ID: 0x23b

    If I launch terminal from:
    Applications -> Utilities -> Terminal

    If I type something, then press command + c keys, nothing happens. I am expecting the line to be broken as if I pressed delete all the way back then return the return key.

    Similarly, if I tried to tar a directory, then press command + c keys as it performs the operation, nothing happens.
  6. robbieduncan Moderator emeritus


    Jul 24, 2002
    Command-C is copy. Control-C is control-C.
  7. Hmac macrumors 68020

    May 30, 2007
    Midwest USA
    Everybody is telling you to use control-c and you are responding by saying that command-c doesn't work.

    Try using control-c ?
  8. Decollete thread starter macrumors newbie

    May 17, 2010
    Wow, I completely missed that key. I knew it was not the caps button, but it never occurred to me to even look at what button that is exactly. Thanks!

    I checked the net for Mac keyboard layouts and found mine to be strange. My caps key is on the same row as option, command, etc. while my control key is on the same row as asdf.
  9. sammich macrumors 601


    Sep 26, 2006
    Usually it helps to try all the modifier keys if you're lost.
  10. BlueRevolution macrumors 603


    Jul 26, 2004
    Montreal, QC
    You can remap them under  -> System Preferences -> Keyboard (or Keyboard & Mouse pre-10.6) -> Keyboard -> Modifier Keys.
  11. levocsamac macrumors newbie

    Feb 9, 2014
    control-c in MAC terminal

    new to MAC, had the question in the title, searched google, wound up on this page, found none of the answers were helpful. used MAC terminal help and found (surprisingly)
    "Break.......Typing Command-Period (.) is equivalent to entering Control-C on the command line"

    It works too.

    The disappointing thing is that I've been using windblows for 30 years and linux for 20 and both of them have been using control-c (like CPM did) for good reason. Why would apple need to change it?
  12. gnasher729 macrumors P6


    Nov 25, 2005
    The majority of Mac users have never in their life used Control-C. A significant number of Mac users have used Command-period, because that has always been the standard way to stop operations. And those who haven't will never need to learn either.
  13. AlanShutko macrumors 6502a

    Jun 2, 2008

    They didn't. Control C works in terminals. It does not work outside of terminals, just as it does not in Windows or Linux.
  14. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    The first Mac keyboards didn't have a control key. None at all.

    Mac Plus keyboards didn't have a control key, either.

    I'd have to look it up, but I don't think an actual control key appeared until the ADB keyboards arrived. I definitely have a control key on an Apple Extended Keyboard II (which is still in regular use, via an ADB-to-USB adapter).

    The command to interrupt or abort the current operation was usually an "Abort" or "Interrupt" or "Stop" menu-item in a menu. Since it was a menu-item, the convention of assigning it a command-key applied. The conventional command-key was command-period (there was a contemporaneous Apple UI guideline that stated this).

    I probably have a very early version of MPW on a CD, and its "interrupt" key is undoubtedly command-period. I could probably dig up an early version of some BBS/terminal program like MacTEP that also uses the command-period convention.

    FWIW, BBS programs like MacTEP would often have an option to disable command-key menu-shortcuts, and let all command-keys (e.g. cmd-C, cmd-X, etc.) be interpreted as ctrl-keys by the app.

    In any case, now that Apple keyboards have a control key, you can continue using ctrl-C.

    I find that I go back and forth between ctrl-C and command-period. The command and period keys are adjacent on all my keyboards, so my right index finger touching my right thumb together can easily produce the keystroke. Obviously, this depends on the keyboard.
  15. smithrh macrumors 68020


    Feb 28, 2009
    I'll further note that Command - period predates both Windows and Linux, so Apple didn't change anything.

    Why didn't Microsoft and Linux follow Apple's example, that would be a better question.
  16. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    Control-C as an abort or interrupt keypress goes back to at least TOPS-10 and TOPS-20, which is roughly the mid to late 1960's:

    No command key.

    Also see:
  17. macrumnev macrumors newbie

    Oct 29, 2013
    break a while loop

    is there a key that will stop a while loop?

    none of those work
  18. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    In what program or programming language?

    Details are important.
  19. macrumnev macrumors newbie

    Oct 29, 2013
    just the command line

    while true; do ping -c 3 yahoo.com; done

    I can't stop this. I have to close the terminal to stop it.

    In a Mac terminal I can't stop this.

    On a Windows host and a Linux VM, control-c stops it.
    On a Mac OSX host and a Linux VM, control-c does not stop it.
  20. chown33, May 28, 2015
    Last edited: May 28, 2015

    chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    Since the ping command will loop indefinitely by default, try this:
    ping yahoo.com
    It will continue to ping until interrupted by control-c or command-period. I see no reason to define a loop external to ping itself.

    The way your loop is written, the exit status of ping has no effect on the continuation condition of the loop. That is, when ping is terminated due to interrupt (control-c or command-period), it will exit with a non-zero status it exits with a status of zero (success). Unfortunately, that has no effect on the while statement, whose only condition is the 'true' command, which always returns true (successful exit status).

    My initial reply was slightly wrong. It turns out that ping exits with a 0 status even when it's been interrupted. This is certainly unconventional when compared to other commands, but it's arguable whether it's a bug.

    To test ping, run this, then interrupt it after 5 results by pressing command-period or ctrl-c:
    ping -c 10 google.com; echo " -- status: $?"
    In any case, ping will loop indefinitely by itself, so an external loop is superfluous.
  21. macrumnev macrumors newbie

    Oct 29, 2013
    First, you didn't read the thread, which asks about stopping something on the command line, then you assume some idiot is working in some language he doesn't know anything about. Then you have some smug comment about "details are important" like I'm a child. Yeah, they are, SO READ THEM.

    I don't really care if you see no reason or not to loop a ping, that was the question. If you can't answer a question, then don't. The reason the ping is in there is just a simple filler example to replace my 5 commands that I'm sure you would judge and criticize, so I took those out, and put the ping in. Also, smarty, what if I need the ping count to stay under 4? What if the ping failed every third time? What if I wanted to alternate a 'date' command so I knew exactly when the pings were done instead of 10,000 pings with no time stamps. I might want to increment the payload, or change the intervals. Plenty of reasons, but again, I didn't ask for a tutorial on ping simplification.

    Also your other thesis falls apart with the facts at hand. Control-c stops it on Linux VM under a Windows Host, but not under a Mac host in a terminal or Linux VM.
  22. dyt1983 macrumors 65816

    May 6, 2014
    They do work as pointed out in this thread. If you don't see that they work, then it's just not on the Mac you're trying. Therefore, you should look why it doesn't work on the Mac with which you're having the problem. I suggest your keyboard mappings first:

     -> System Preferences -> Keyboard -> Keyboard -> Modifier Keys

    (as pointed out in post #10 in this thread)

    To be fair, you didn't include details in your first post in the thread, after it was pointed out that those keys work... so if you include the details, it would help determine what exactly you're doing that isn't working. Your second post did include the details though.
  23. chown33, May 28, 2015
    Last edited: May 28, 2015

    chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    I did read the thread. In fact, I reread it, including my earlier replies. I also went and read your other posts, few though they were, to see if they shed any light on your experience level or gave insight into what kind of while loop you were referring to. Other than what you posted, I have no way of knowing what you know, or guessing what you might mean.

    If you're having trouble with a specific command-line construct, then you need to post it, in the exact form that's causing the problem. Putting in fillers and placeholders may not work. You agreed that details are important, yet you posted an example whose details differed from the command-line you were having problems with.

    One reason for posting the exact command-line you're having problems with is to replicate the problem here on my machine, and to study ways of solving the problem. If you post a different problem, then all I can do is to study the problem you posted.

    One of the ways to solve problems is to restructure them. That's what I did with the ping example you posted. If you'd posted the actual commands you were having trouble with, I would have studied those. I might not have found a solution, but at least I'd be looking for a solution for what you were actually having a problem with. Since you didn't post it in any of your replies, I can't possibly offer any other ideas for solutions.

    To see how ctrl-c or command-dot stops a while loop in the shell, try these:
    while true; do true; done
    while true; do false; done
    while true; do sleep 5; done
    You should see that each of these is interruptible. This suggests the problem isn't with the while/do/done per se, but something else. That's just a guess, since we still don't know exactly what commands you're having trouble with.
  24. gnasher729 macrumors P6


    Nov 25, 2005
    Recommended reading: Dale Carnegie, How to Make Friends and Influence People.
  25. Wondercow macrumors 6502a

    Aug 27, 2008
    Toronto, Canada
    You're absolutly right; it's too bad chown33 couldn't just answer the question as that would have been the best, most helpful contribution.

    So, please allow me to help: "is there a key that will stop a while loop?"


    I trust that will satisfy your high standards.

Share This Page