• 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: detecting logout
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: detecting logout


  • Subject: Re: detecting logout
  • From: Jerry Pendergraft <email@hidden>
  • Date: Tue, 1 Feb 2005 16:14:38 -0600 (CST)

This idea assumes your users are defined with /bin/sh or /bin/bash as
their login shell. Since they don't do anything with command line they
should not care anyway.

Even though you can't reasonably modify each users login script you should
be able to modify /etc/profile which is run by all logins - I think that
includes ssh sessions.

You fire up your daemon in /etc/profile after setting a "trap" to stop it.
trap EXIT "your-kill-command"
your-start-up-command

Then on logout (aka exit from the shell) your daemon should be killed.

--
Jerry Pendergraft                        email@hidden
Endocardial Solutions                    voice: 651-523-6935
1350 Energy Lane, Suite 110                fax: 651-644-7897
St Paul, MN 55108-5254                  mobile: 651-491-0163

On Tue, 1 Feb 2005, Pete Gontier wrote:

> By the way, the triple-posting of my original message didn't come from me.
> According to the headers of the duplicates, someone else re-sent my message
> twice. I guess we'll see if it happens again for this message. :-)
>
> circa 2/1/05 12:16 PM, "Graham J Lee" <email@hidden>
> wrote:
>
> > Does the user's .logout script (or whatever alternative bash has) get
> > run when they log out of the console environment?  If so, you launch
> > your daemon from .login, and cause it to write its pid into
> > ~/.mydaemonname.pid, and then .logout contains the line "kill -QUIT
> > `cat ~/.mydaemonname.pid`".
>
> If this script does run, and I doubt it does since typically such things are
> only run as part of a terminal session, I can't really exploit this
> reasonably because such scripts are arbitrarily complex and thus very
> difficult to reliably modify programmatically (especially on uninstall), and
> our users have no command-line expertise so can't do it themselves.
>
> > Of course, if it doesn't get run, then you probably need to use a
> > logouthook.  But that would make you a customer of the WindowServer,
> > which you don't want (understandably, because then users who ssh in
> > don't get to kill their daemons).
>
> I got an additional message off-list containing a link to a page on logout
> hooks.
>
>     http://developer.apple.com/documentation/
>         MacOSX/Conceptual/BPSystemStartup/Tasks/CustomLogin.html
>
> I read this far and stopped:
>
>     you must modify the code for launching loginwindow found in /etc/ttys
>
> Wow. I am definitely not in a position to do that.
>
> I suppose I should consider kAEQuitApplication, but I am not sure how I am
> going to listen to that without attaching to the window server. I have heard
> there are lower-level ways to do Apple events, but I have never used them.
>
>   --
>
>     Pete Gontier
>     http://www.m-audio.com/
>
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Darwin-dev mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: detecting logout (From: Pete Gontier <email@hidden>)

  • Prev by Date: Re: detecting logout
  • Next by Date: Re: detecting logout
  • Previous by thread: Re: detecting logout
  • Next by thread: Re: detecting logout
  • Index(es):
    • Date
    • Thread