Top: how to cancel current command

top

While browsing processes on a shared server in top I accidentally hit the r key which prompted me with renice. I had no clue what this was going to do with my input and found no way to go back.

I tried ^C, ^D, <ESC> among other things and ended up just typing some garbage like asdf; which got me out. Is there a sane way to cancel a command that you type interactively in top?

Best Answer

When prompted for the PID to renice, entering any value that isn't a positive integer will exit the renice mode with an error message. Once you enter a PID, however, you are stuck entering a priority; any invalid entry will cause the get_int function to return -1, which will set the priority to -1. The only way to avoid entering a priority is to kill top. Ctrl-C should work. Ctrl-D or enter will cause the niceness to be set to -1.

Source: Procps source code

Related Question