views:

5387

answers:

4

Duplicate:

generate a core dump in linux

I am trying to create a core dump in my "Fedora Core release 3 (Heidelberg)".

[root@testserver test_core_dump]# uname -a

Linux testserver 2.6.12-1.1381_FC3 #1 Fri Oct 21 03:46:55 EDT 2005 i686 athlon i386 GNU/Linux

I am following this to create core dumps.

The problem is, /proc/sys/kernel/suid_dumpable is not present in this version. I also checked here /proc/sys/fs/suid_dumpable, but suid_dumpable is not present.

1) Is there any work around for this? 2) Am I missing something here?

+4  A: 

The instructions you are following are simply to over-ride the o/s limits that may prevent you from getting a core dump.

The generation of a core dump is a trivial process, you send a signal to the process as follows

kill -ABRT pid_of_process

There are many things however that may prevent this from happening, however you should try this first and see if it produces a core dump in your current directory. If the program is interactive and doesn't trap the quit signnal then you may be able to cause core to dump by sending SIGQUIT to the process, this is usually bound to CTRL-\

The area you are having problems with in the referenced document refers to process that run setuid/setguid if your process is not running in either of those modes then you can safely ignore that step. (You can tell if the process is running setuid/setguid by looking at the file permissions of the program and examining the setuid and setguid bits this can be done by issuing an ls -l command and looking for s in the 4th position (setuid) or 7th position (setgid) (example of setuid below)

-r-sr-xr-x 1 root wheel 57616 28 Oct 03:28 /usr/bin/login

Have you tried to generate a core without using the step that is not working and did it work?

You will need to be able to write in the directory that the process is running in, or the directory defined for core dumps if that is not the current directory. Running as root may solve the permissions issues.

Steve Weet
yes, you are right. This works without setting, suid_dumpable. Thanks for your help :).
Manohar
+1  A: 

I am not sure I understand what you want. The webpage you references talks about ENABLING core-dumps, not triggering them. Do not worry about the missing sysctl -- my Linux systems also doesn't have it and I can happily dump cores all around :) Do you want to create a core dump for a specific process?

Apart from SIGABRT, you can also try using gcore:

NAME gcore - Generate a core file for a running process

SYNOPSIS gcore [-o filename] pid

DESCRIPTION gcore generates a core file for the process specified by its process ID, pid. By default, the core file is written to core.pid, in the current directory.

ShiDoiSi
I have a program that crashes, After it crashes I want to know the stack trace. coredump can give me that. I am trying to enable this before program starts, so that once the program crashes I would know where exactly it is crashing. This is what I am trying to achieve here.
Manohar
A: 

This is a duplicate of this question. The accepted answer, and the one with most votes suggest the following:

In Bash:

ulimit -c unlimited

and in tcsh:

limit coredumpsize unlimited

In this case, if a program crashes, the core dump will be created in a file called core where the program was run.

Nathan Fellman
yes, ulimit -c unlimited is enough for core dumping. But where is it creating the coredump?
Manohar
the core dump will be created in a file called core where the program was run.
Nathan Fellman
A: 

Thank you!!! This was great info. the gcore command worked for me. The other commands didn't generate any core dumps.

I appreciate it.

Andy D. http://www.FranklinFaces.com

Andy D