Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can one send a Ctrl-Break to a running Linux process?

I am debugging a memory leak in an application running on Sun's JDK 1.4.2_18. It appears that this version supports the command line param -XX:+HeapDumpOnCtrlBreak which supposedly causes the JVM to dump heap when it encounters a control-break. How does one send this to a background process on a Linux box? It appears that kill signals are the way this ought to work, but I kill -l doesn't report anything that is obviously a Ctrl-Break, at least on my Ubuntu box.

Update: I tested Kill -3 with Sun JDK 1.4.2_18 (_14 was the first to dump heap this way), and it worked. A heap dump file was created, and the process was still running.

like image 685
ShabbyDoo Avatar asked May 11 '09 21:05

ShabbyDoo


People also ask

What is control Break command?

(ConTRoL-Break) In a Windows PC, holding down the Ctrl key and pressing the Break key cancels the running program or batch file. See Ctrl-C.

How do you Ctrl a terminal in Linux?

Ctrl+A or Home – moves the cursor to the start of a line. Ctrl+E or End – moves the cursor to the end of the line. Ctrl+B or Left Arrow – moves the cursor back one character at a time.

How do you stop a Ctrl C process in Linux?

Turned out the way Ctrl-c works is quite simple — it's just a shortcut key for sending the interrupt (terminate) signal SIGINT to the current process running in the foreground. Once the process gets that signal, it's terminating itself and returns the user to the shell prompt.

How do I stop a running command in terminal?

Then we hit Ctrl+C to terminate the execution.


2 Answers

Ctrl-\ is the UNIX/Linux equivalent of Windows Ctrl-Break. Wikipedia also tells me that you can also use Ctrl-4 or SysRq on the Linux virtual console (I guess you'd need something weird for a normal terminal emulator to pass representations of those key presses (over ssh/telnet)).

like image 169
Tom Hawtin - tackline Avatar answered Sep 30 '22 14:09

Tom Hawtin - tackline


kill -QUIT might do it (it will generate a thread dump which is generated by ctrl-break on windows. I haven't tried it with the heap dump option though).

like image 43
bm212 Avatar answered Sep 30 '22 16:09

bm212