Professional Web Applications Themes

Daemons on Mac OS X - Mac Programming

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 ...

  1. #1

    Default 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

  2. #2

    Default Re: Daemons on Mac OS X

    In article <4beb34a4.0309181751.17857b6posting.google.com> ,
    [email]rgasparini29[/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,
    Eric

    --
    Eric Albert [email]ejalbertstanford.edu[/email]
    [url]http://rescomp.stanford.edu/~ejalbert/[/url]
    Eric Albert Guest

  3. #3

    Default 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 <ejalbertstanford.edu> wrote in message news:<ejalbert-36C073.00483219092003news.stanford.edu>...
    > In article <4beb34a4.0309181751.17857b6posting.google.com> ,
    > [email]rgasparini29[/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,
    > Eric
    Jorge Guest

  4. #4

    Default Re: Daemons on Mac OS X

    In article <4beb34a4.0309190719.300a216bposting.google.com >,
    [email]rgasparini29[/email] (Jorge) wrote:
    > 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??
    It gets terminated when its connection to the window server exits. I
    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]ejalbertstanford.edu[/email]
    [url]http://rescomp.stanford.edu/~ejalbert/[/url]
    Eric Albert Guest

  5. #5

    Default Re: Daemons on Mac OS X

    [email]rgasparini29[/email] (Jorge) wrote:
    > 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 ...
    If I were to venture a guess, perhaps the window server is killing
    everything attached to it at logout, rather than going away itself?

    --
    William Edward Woody - [email]woodyalumni.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

  6. #6

    Default Re: Daemons on Mac OS X

    In article <4beb34a4.0309181751.17857b6posting.google.com> ,
    [email]rgasparini29[/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?
    >
    > Any help or suggestion will be highly appreciated ...
    > thanks in advance,
    There's an extremely ugly hack which isn't compatible with Panther. It
    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

  7. #7

    Default Re: Daemons on Mac OS X

    On Fri, 19 Sep 2003, Mike Cohen wrote:
    > In article <4beb34a4.0309181751.17857b6posting.google.com> ,
    > [email]rgasparini29[/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?
    I think you need to link againt CoreServices rather than Carbon.

    Fred

    Frederick Cheung Guest

  8. #8

    Default 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 doented here:
    [url]http://developer.apple.com/doentation/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 <fglc2srcf.DUH.ucam.org> wrote in message
    > I think you need to link againt CoreServices rather than Carbon.
    >
    > Fred
    Jorge Guest

Similar Threads

  1. daemons & emails
    By SINNER in forum Ubuntu
    Replies: 4
    Last Post: March 7th, 06:12 PM
  2. snmp related daemons
    By Andy in forum AIX
    Replies: 0
    Last Post: July 8th, 08:15 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139