NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: dump core while running



On Tue, Mar 03, 2009 at 05:04:36PM +0100, Ignatios Souvatzis wrote:
> Hi,
> 
> On Tue, Mar 03, 2009 at 05:14:33PM +0200, Brad du Plessis wrote:
> 
> > Is there a way from within a userland app to get it to core dump and 
> > keep running?
> sort of, see below.
> 
> > I'd like to see a full back trace with symbols etc. when a 
> > certain error (which is handled) happens within my code but I'd like the 
> > app to continue running. Searched a bit and couldn't find anything that 
> > dumps the core without killing the app too.
> 
> I believe this is good enough:
> 
> #include <unistd.h>
> #include <signal.h>
> 
> if (condition) {
> 
>       pid_t pid;
> 
>       pid = fork(); /* or vfork(), which might be faster - less MMU load */
>       if (pid == 0) {
>               kill(getpid(), 9);

Actually, make that
                kill(getpid(), SIGTRAP);
                pause();
>       }
>       
> }
> 
> Regards,
>       -is


Home | Main Index | Thread Index | Old Index