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

Re: Dumping Core on Purpose



> 
> Is there any way to make a program dump core and then continue execution?
> Sorta like taking a snap-shot of the current program state.
> 
>                                           Brian
>                                  ( bcwhite@verisim.com )
> 

That's an interesting idea :).  Let me see, I think I would try
something like

void dump_core(void) {
  pid_t childpid;

  childpid = fork();
  switch (childpid) {
    case -1:
      /* complain fiercely: couldn't fork() */
    break;
    case 0:
      /* in the child here: let's dump core */
      abort();
    break;
    default:
      /* in the parent, lets wait for the child's death to prevent zombie
         formation, and then proceed */
      waitpid(childpid, NULL, 0);
  }
}

Of course, this is all untested vaporware, and you are happily
encouraged to check out the man pages on fork, abort and waitpid and
include the proper header files.

HTH,
Eric Meijer

-- 
 E.L. Meijer (tgakem@chem.tue.nl)          | tel. office +31 40 2472189
 Eindhoven Univ. of Technology             | tel. lab.   +31 40 2475032
 Lab. for Catalysis and Inorg. Chem. (TAK) | tel. fax    +31 40 2455054


--  
Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null


Reply to: