Re: Trapping user shutdown/logout/restart in Cocoa/Foundation tool
Re: Trapping user shutdown/logout/restart in Cocoa/Foundation tool
- Subject: Re: Trapping user shutdown/logout/restart in Cocoa/Foundation tool
- From: "parag vibhute" <email@hidden>
- Date: Tue, 8 Jan 2008 21:19:41 +0530
Hi andrew,
Thanks for reply. I have a requirement to run the application, not to show
application icon in dock & to trap shutdown, restart, logout. As Jean-Daniel
said, there are other ways to capture the logout,restart,shutdown. But it
seems that those ways are particularly created for daemon otherwise in cocoa
application, it is rarely that anybody will use those techniques for
capturing logout/restart/shutdown; programmer will use workspaceWillPowerOff
notification. Those techniques are particularly useful to differentiate
between logout, restart & shutdown notification. I went through technote
which you suggested, but for creating daemon, I will need to implement plist
& I can't do that. I can only make changes in code of my application. I
can't create plist & stuff like that. I read that in order to control the
daemon by launchd, do not use "daemon" API. Also checked that if you launch
the application in C program using system api & concating "&" at the end of
path (like system "./testapp &"), application runs in background & its
parent process become launchd. But it doesn't affect. Yes you are right that
technote mention that do not link daemon to non-daemonized framework. But I
think that statement is only concerned if you want to relate daemon to inetd
or launchd etc. Using "daemon" API only in code does not make application
daemon.
Any comments.
Thanks,
Palav
On Jan 8, 2008 2:55 PM, Andrew Farmer <email@hidden> wrote:
> On 08 Jan 08, at 00:11, parag vibhute wrote:
> > Is anybody there?
> >
> > Please reply.
>
> No, there is nobody here. Our activity on this mailing list is a
> massive hoax.
>
> Seriously, though:
>
> On 1/5/08, parag vibhute <email@hidden> wrote:
> > While going through code snippets given in QA, I observed that apple
> > used *
> > daemon* API to run process in background. In my cocoa application, I
> > just
> > added daemon(0,0) line in my main function & using LSUIElement, hide
> > the
> > application icon. Now even though dock icon is hidden, my
> > application is
> > able to trap logout/restart/shutdown in
> > -(void)workspaceWillPowerOff:(NSNotification
> > *)aNotification. Want to know whether this way is correct? or is it
> > having
> > any drawback?
>
> It has some significant drawbacks. Read Tech Note 2083 [1]. In
> particular, daemon() is deprecated under Mac OS 10.5, and a number of
> frameworks (including Core Foundation!) are unsafe to call from a
> daemon (forked-without-exec) context.
>
> [1]: http://developer.apple.com/technotes/tn2005/tn2083.html
>
--
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