How can I make core dump manualy?

Hello everybody. How can I make core dump of my program manualy? I mean syscall like do_coredump() in linux. Handler of SIGSEGV is defined (so there are no default behavior) and do something and I want it to make core dump too. thanks.
 
anemos said:
I think that
Code:
kill(getpid(), SIGSEGV);
will do that.

no. SIGSEGV handler will catch signal and handle it without core dump. I need to do core dump inside of SIGSEGV handler.
 
Last time I required a core file, I think it was a matter of enabling core dumps with ulimit, and sysctl kern.core=1.
 
no, the OS has capability to make core files. again, i need to make core dump of my program by myself from inside of the propgram (via syscall or so). i cannot find the name of such function, that's i want. in linux it calls do_coredump() and what about FreeBSD?
 
Possibly not what you're after, but in the signal handler maybe you can reset the SEGV action back to default, and then send a SEGV signal to yourself.
 
Why? What do you mean beautiful?
From a quick "scan" I did in src/sys/kern/syscalls.master I concluded that there is not such a system call in FreeBSD.

coredump() is the kernel routine which dumps a process but there is not a system call so you can reach this function.
So, as far as I can tell, you have two options:
either you write your own system call as a dynamically loadable kernel module, or you follow aragon's suggestion.

I would be interested though to see what you'll end up with.

Regards
 
I don't know what language you are using, but I think there should be a syscall to do that. F.ex. in perl:
Code:
perl -e 'dump'
 
Other then CORE::dump is obsoleted, I always thought the core dump it was based on perl opcodes rather then the perl binary.
 
simples!

Code:
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>


int main(int argc, char ** argv) {


    kill(getpid(), SIGQUIT);
}
 
bigearsbilly said:
simples!

Code:
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>


int main(int argc, char ** argv) {


    kill(getpid(), SIGQUIT);
}

What about hitting ^\ on the keyboard? :)
 
Back
Top