Walker News

How To Forcibly Generate Core Dump File On Linux For Testing?

Question: How do you purposely crash a program to generate core dump file, in order to confirm or verify that the Linux is properly configured to allow core dump?

You probably know that Linux only allows a crashed program to generate core dump if the ulimit is configured properly.
On Red Hat Enterprise Linux, the default value of ulimit -Sc is 0, indicates it doesn’t allow core dump.

Let’s say you’ve configure it to unlimited:
ulimit -Sc unlimited

Next, how could you simulate a test to prove the setup is working? Well, it could be as simple as the one shown in this silent screencast:

1. Create a Bash shell script called tst that contains a simple while loop:

while true
  echo "PID is $$"
  sleep 100000

2. Execute tst and note down its process ID (PID).

3. On another Linux command prompt, send a SIGILL signal to the PID shown by step-2, i.e. uses kill command to send the signal:
kill -4 pid-of-step-2

If the ulimit -Sc is set properly, it should generate the core.PID file as well as message shown after the killed shell script process.

Custom Search

2017  •  Privacy Policy