Re: Catching Cocoa application Crash
Re: Catching Cocoa application Crash
- Subject: Re: Catching Cocoa application Crash
- From: "arri mafkees" <email@hidden>
- Date: Sat, 9 Feb 2008 01:34:54 +0100
On Feb 8, 2008 2:00 PM, parag vibhute <email@hidden> wrote:
> Ok. Following is what I am doing in my code:
> 1. I have created a named pipe in /tmp folder.
> 2. My requirement is to remove it when my application quits.
> 3. Imp. thing is my application runs in user session & can't be launched
..but your app can on launch register an agent with launchd that you
unregister after closing the pipe just before exitting or that will be
executed by launchd if your app didn't exit cleanly
> using lauch agent.
> 4. I selected /tmp folder bcoz if user shutdowns abruptly then on next
> reboot, /tmp folder gets cleared.
> 5. But in same user session, suppose if my application gets crashed then
> that file does not get deleted.
>
> So want to trap the application crash.
>
> Thanks,
> Palav
>
> On Feb 8, 2008 5:44 PM, Nir Soffer <email@hidden> wrote:
>
> >
> > On Feb 8, 2008, at 10:37, parag vibhute wrote:
> >
> > > I have developed a cocoa application. On termination of that
> > > application, I
> > > am performing some task(deleting a file). For this I have implemented
> > > applicationshouldterminate delegate which gets called when user
> > > quits the
> > > application properly.
> > >
> > > But there are certain times when that application gets crashed. My
> > > question
> > > is can we trap this application crash event so that I can perform
> > > that task?
> >
> > You cannot do anything when you crash or someone kill you. Even if
> > you can is some cases, your cleanup may fail.
> >
> > The best solution in this case would be to open that file and
> > immediately unlink it. You can continue to read and write to the
> > file, and it will disappear when you process is gone.
> >
> > Other more complicated options:
> >
> > - Run your app behind a watchdog process, responsible for cleanup. In
> > this case, it does not matter how you exit, cleanup is always done
> > correctly. Except the case when the watchdog itself crash or killed.
> >
> > - Do the cleanup on startup if the app did not exit cleanly. For
> > example there is a key in your preferences
> > "ApplicationCrashedAfterRelaunch" that the system seems to set. You
> > can also have your own key that
> >
> > You probably need to give more details to get the best solution for
> > your specific use case.
> >
> >
> > Best Regards,
> >
> > Nir Soffer
>
> >
> >
>
>
> --
>
> There are many things in your life that will catch your eye but only a few
> will catch your heart....pursue those'.
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden