Operating System - HP-UX
1820477 Members
3018 Online
109624 Solutions
New Discussion юеВ

core files with $kill -3 pid

 
SOLVED
Go to solution
Shivkumar
Super Advisor

core files with $kill -3 pid

Hi,

The command $kill -3 pid (of java process) produces java core dump files.

If I execute $kill -3 (with the pid of some other application) then will core files would get produced ?

Thanks,
Shiv
7 REPLIES 7
Bill Hassell
Honored Contributor
Solution

Re: core files with $kill -3 pid

Yes. kill -3 will immediately terminate any process (not just Java) and produce a core dump. See the man page for kill.


Bill Hassell, sysadmin
Arunvijai_4
Honored Contributor

Re: core files with $kill -3 pid

Hi Shiv,

Signal 3 is SIGQUIT. It produces a core dump on abort.

3 SIGQUIT Quit Terminate with core dump; can be trapped

Check "man kill" for more information,
http://docs.hp.com/en/B2355-60127/kill.1.html

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
A. Clay Stephenson
Acclaimed Contributor

Re: core files with $kill -3 pid

Well, to be accurate sending a SIGQUIT (kill -3) to a process has the behavior that is determined by the signal handler currently in place for that signal for that process. The default action is to generate a core dump and terminate but the actual behavior could be almost anything -- including ignoring that signal. Man 2 kill and 2 signal for details.
If it ain't broke, I can fix that.
Steven E. Protter
Exalted Contributor

Re: core files with $kill -3 pid

Shalom Shiv,

So the kill -3 will normally produce a core dump of the process running as its designed, unless the signal handler has been changed.

Quite useful for any process that is misbehaving.

I can see reasons why some application vendors would try and avoid core dumps with use of signal handling.

You will not get core dumps if you have disabled core dumps in /etc/profile or .profile of the user or script that starts the process.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Shivkumar
Super Advisor

Re: core files with $kill -3 pid

Why some folks says that said we should not be taking core dump using $kill -3 pid (of a application) in production servers ?

Is taking core dump affects applications or operating system ?

Thanks,
Shiv
Bill Hassell
Honored Contributor

Re: core files with $kill -3 pid

Well, killing a production process may or may not be an appropriate action for the porcess. As Clay mentioned, several signals can be trapped and the application take the appropriate action, but many programmers don't handle all (or any) signals and the process abnormally terminates. Depending on the way the program works, data files may become corrupted. So indiscriminate kill commands can be bad for production programs and data.

However, kill -3 may be the only way a programmer can find out why a process is not working correctly, so it may be required. Now kill -3 (when it results in a core file) is unique in that the process memory area is copied to a disk file. That doesn't sound like much but it actually creates a heavy load on the system due to the tasks needed to rearrange memory. This causes spinlocks which are short pauses where all processing stops until the cire dump is complete. That may be the reason you heard that it's not a good idea to have core dumps on a running system.

Now that doesn't mean you should ban the practice. As with any heavy load on the system (like find / or du /), you don't do it very often. But if a core dump is the only way to discover the programming problem, then you'll have to do it. Note that the core dump does not introduce any instability in the system...it just slows down for a few seconds.

As Steven mentioned, you can limit core dumps as to size including zero (which prevents any core dump). The ulimit command in the shell can limit the maximum size of a core dump. Note that ulimit -c onloy works with the POSIX shell or a recently patched version of ksh.


Bill Hassell, sysadmin
Shivkumar
Super Advisor

Re: core files with $kill -3 pid

My best regards and thanks to great system Admin Bill, Clay and Steven for providing such a great explanation.

-Shiv