Ask a Question related to Mac Programming, Design and Development.
-
Jorge #1
Daemons on Mac OS X
Hello,
I have create a background-only application using CarbonLib with
CodeWarrior 8. This app tracks application usage and saves the
information in a log file.
To launch my application at startup, I need to create a script and
configure it in /Library/StartupItems ... This script launches the
Carbon app using the "open" command :
open /Library/StartupItems/Resources/myCarbonApp
So far, it works fine, after startup I can see my process using
"Process Viewer". However, the process is terminated at logout and is
no more launched.
So how do I make my process immune from termination at logout? Could
be CarbonLib usage the source?
Any help or suggestion will be highly appreciated ...
thanks in advance,
Jorge Guest
-
daemons & emails
* Richard G. Riley wrote in alt.os.linux.ubuntu: Install procmail and use /usr/bin/formail -- David Very few profundities can be expressed... -
snmp related daemons
I'd like to disable following daemons in /etc/rc.tcpip. Is it good idea having HACMP configured on the machine...? # Start up the hostmibd... -
Eric Albert #2
Re: Daemons on Mac OS X
In article <4beb34a4.0309181751.17857b6@posting.google.com> ,
[email]rgasparini29@yahoo.com[/email] (Jorge) wrote:
That is not the right way to launch a Carbon application. Though the> I have create a background-only application using CarbonLib with
> CodeWarrior 8. This app tracks application usage and saves the
> information in a log file.
>
> To launch my application at startup, I need to create a script and
> configure it in /Library/StartupItems ... This script launches the
> Carbon app using the "open" command :
>
> open /Library/StartupItems/Resources/myCarbonApp
subject line of your posts refers to daemons, Carbon applications aren't
daemons because they connect to the window server. Applications that
connect to the window server should not be startup items. They can be
per-user login items, launched when a user logs in and closed when the
user logs out.
That's because it connects to the window server.> So far, it works fine, after startup I can see my process using
> "Process Viewer". However, the process is terminated at logout and is
> no more launched.
You need to build a Mach-O application and not link against any> So how do I make my process immune from termination at logout? Could
> be CarbonLib usage the source?
framework that pulls in the window server (e.g. Carbon or AppKit). If
you can limit your app to CoreServices or CoreFoundation, it'll work.
Hope this helps,
Eric
--
Eric Albert [email]ejalbert@stanford.edu[/email]
[url]http://rescomp.stanford.edu/~ejalbert/[/url]
Eric Albert Guest
-
Jorge #3
Re: Daemons on Mac OS X
Thank you very much, Eric ... I will to try your suggestions. Just one
more doubt about this, you say that my "daemon" is terminated because
it connects to the window server, why is not terminated at first
login?? ... When I restart my computer and I login the first time, the
"daemon" is alive and working ... it is terminated when I logout and
login again ...
Thanks in advance ...
Eric Albert <ejalbert@stanford.edu> wrote in message news:<ejalbert-36C073.00483219092003@news.stanford.edu>...> In article <4beb34a4.0309181751.17857b6@posting.google.com> ,
> [email]rgasparini29@yahoo.com[/email] (Jorge) wrote:
>>> > I have create a background-only application using CarbonLib with
> > CodeWarrior 8. This app tracks application usage and saves the
> > information in a log file.
> >
> > To launch my application at startup, I need to create a script and
> > configure it in /Library/StartupItems ... This script launches the
> > Carbon app using the "open" command :
> >
> > open /Library/StartupItems/Resources/myCarbonApp
> That is not the right way to launch a Carbon application. Though the
> subject line of your posts refers to daemons, Carbon applications aren't
> daemons because they connect to the window server. Applications that
> connect to the window server should not be startup items. They can be
> per-user login items, launched when a user logs in and closed when the
> user logs out.
>>> > So far, it works fine, after startup I can see my process using
> > "Process Viewer". However, the process is terminated at logout and is
> > no more launched.
> That's because it connects to the window server.
>>> > So how do I make my process immune from termination at logout? Could
> > be CarbonLib usage the source?
> You need to build a Mach-O application and not link against any
> framework that pulls in the window server (e.g. Carbon or AppKit). If
> you can limit your app to CoreServices or CoreFoundation, it'll work.
>
> Hope this helps,
> EricJorge Guest
-
Eric Albert #4
Re: Daemons on Mac OS X
In article <4beb34a4.0309190719.300a216b@posting.google.com >,
[email]rgasparini29@yahoo.com[/email] (Jorge) wrote:
It gets terminated when its connection to the window server exits. I> Thank you very much, Eric ... I will to try your suggestions. Just one
> more doubt about this, you say that my "daemon" is terminated because
> it connects to the window server, why is not terminated at first
> login??
believe the window server doesn't get relaunched when the first user
logs in; instead, it gets its ownership ratcheted down from root to the
user who's logging in. Or something like that. :) I'm not 100% certain
of the reason, but I'm confident that my general explanation is right. :)
-Eric
--
Eric Albert [email]ejalbert@stanford.edu[/email]
[url]http://rescomp.stanford.edu/~ejalbert/[/url]
Eric Albert Guest
-
William Woody #5
Re: Daemons on Mac OS X
[email]rgasparini29@yahoo.com[/email] (Jorge) wrote:
If I were to venture a guess, perhaps the window server is killing> Thank you very much, Eric ... I will to try your suggestions. Just one
> more doubt about this, you say that my "daemon" is terminated because
> it connects to the window server, why is not terminated at first
> login?? ... When I restart my computer and I login the first time, the
> "daemon" is alive and working ... it is terminated when I logout and
> login again ...
everything attached to it at logout, rather than going away itself?
--
William Edward Woody - [email]woody@alumni.caltech.edu[/email]
Chaos In Motion - [url]http://www.chaosinmotion.com[/url]
The PandaWave - [url]http://www.pandawave.com[/url]
Freedom is the non-negotiable demand of human dignity;
the birthright of every person‹-in every civilization.
- National Security Strategy of the United States
William Woody Guest
-
Mike Cohen #6
Re: Daemons on Mac OS X
In article <4beb34a4.0309181751.17857b6@posting.google.com> ,
[email]rgasparini29@yahoo.com[/email] (Jorge) wrote:
There's an extremely ugly hack which isn't compatible with Panther. It> Hello,
>
> I have create a background-only application using CarbonLib with
> CodeWarrior 8. This app tracks application usage and saves the
> information in a log file.
>
> To launch my application at startup, I need to create a script and
> configure it in /Library/StartupItems ... This script launches the
> Carbon app using the "open" command :
>
> open /Library/StartupItems/Resources/myCarbonApp
>
> So far, it works fine, after startup I can see my process using
> "Process Viewer". However, the process is terminated at logout and is
> no more launched.
>
> So how do I make my process immune from termination at logout? Could
> be CarbonLib usage the source?
>
> Any help or suggestion will be highly appreciated ...
> thanks in advance,
involves having a daemon which monitors the window manager task and/or
your application and if the window manager's PID changes or your
application isn't running, it obtains the window manager's bootstrap
port and sets its own port to that one before launching your application.
Once again, AVOID DOING THAT IF POSSIBLE.
Could you possibly have your application use CFRunLoop & Mach messaging
instead of AppleEvents or CarbonEvents? That's what I ended up doing -
it took about a week but was well worth the effort.
--
Mike Cohen - mike3k <at> onepost <dot> net
Personal: [url]http://www.mc-development.com/[/url]
Mac News: [url]http://www.macmegasite.com/[/url]
Mike Cohen Guest
-
Frederick Cheung #7
Re: Daemons on Mac OS X
On Fri, 19 Sep 2003, Mike Cohen wrote:
I think you need to link againt CoreServices rather than Carbon.> In article <4beb34a4.0309181751.17857b6@posting.google.com> ,
> [email]rgasparini29@yahoo.com[/email] (Jorge) wrote:
>> > Hello,
> >
> > I have create a background-only application using CarbonLib with
> > CodeWarrior 8. This app tracks application usage and saves the
> > information in a log file.
> >
> > To launch my application at startup, I need to create a script and
> > configure it in /Library/StartupItems ... This script launches the
> > Carbon app using the "open" command :
> >
> > open /Library/StartupItems/Resources/myCarbonApp
> >
> > So far, it works fine, after startup I can see my process using
> > "Process Viewer". However, the process is terminated at logout and is
> > no more launched.
> >
> > So how do I make my process immune from termination at logout? Could
> > be CarbonLib usage the source?
Fred
Frederick Cheung Guest
-
Jorge #8
Re: Daemons on Mac OS X
Thanks to everybody, I'm sorry for the late reply.
Now I tried login scripts and my application works fine. The login
script launches my CarbonLib application as a Background-Only App, and
it works. However, I think this is not the best approach, right?
Login scripts are documented here:
[url]http://developer.apple.com/documentation/MacOSX/Conceptual/SystemOverview/BootingLogin/chapter_4_section_4.html[/url]
Fred, your option sounds fine. But, how can I catch events when an
application brings to front with the CoreServices framework?
Regards ...!
Frederick Cheung <fglc2@srcf.DUH.ucam.org> wrote in message> I think you need to link againt CoreServices rather than Carbon.
>
> FredJorge Guest



Reply With Quote

