• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: how to create a .core file ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to create a .core file ?


  • Subject: Re: how to create a .core file ?
  • From: James Quick <email@hidden>
  • Date: Tue, 24 Jun 2003 02:57:12 -0400

On Monday, June 23, 2003, at 10:23 PM, Lloyd Dupont wrote:

hmm well,.. I don't want my program to quit.
in fact I want it to continue (at least if I catch the error at a higher
level)...
I just want proces snapshot ....
but thanks for the idea :-)

What about forking first, then having the child immediately commit suicide?
...

#import <signal.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>

dumpcore()
{
int status;
int childpid;
struct rlimit corelimit;

/* Set RLIMIT_CORE limit (by default 0) to either the max value, or a hardcoded
smaller value if you want to avoid getrlimit()
*/
getrlimit(RLIMIT_CORE, &corelimit);
corelimit.rlim_cur = corelimit.rlim_max;
setrlimit(RLIMIT_CORE, &corelimit);

childpid = fork();
if (childpid == 0) {
kill(SIGABRT, getpid());
sigpause(0); /* I'm not sure if we could possibly reach this, but if so, wait to die. */
} else if (childpid == -1) {
/* report an error, raise an exception, etc. */
} else {
/* in parent if you want to wait until the child has finished dying. */
wait(&childpid);
}
}

If for some reason you are not ignoring SIGCHLD (the default)
you would use sigprocmask() to prevent delivery of SIGCHLD or
sigaction() to install a handler.

caveat. I am currently isomniac and have not played with signals in a long time.

TIme for bed, hope this helped.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: how to create a .core file ? (From: "Lloyd Dupont" <email@hidden>)

  • Prev by Date: Re: NSOpenPanel woes/questions
  • Next by Date: Re: Xcode...
  • Previous by thread: Re: how to create a .core file ?
  • Next by thread: [ANN] Defaults Manager WWDC Promotion
  • Index(es):
    • Date
    • Thread