• 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
Question on using launchd from a C program
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question on using launchd from a C program


  • Subject: Question on using launchd from a C program
  • From: Mike Kobb <email@hidden>
  • Date: Thu, 8 Jun 2006 15:55:43 -0700

Greetings,

I'm working on a MacOS preference pane that is used to configure the options of a faceless background process (a music server).

This process is a BSD process for historical reasons, but will run under the privileges of a particular user, and not as root.

I want to have a pop-up in the prefs pane that allows the user to choose to manually launch the server (by clicking a "Start" button in the pane, or to have the server launch at startup. Either way, I want to be sure that the server quits when they log out.

It seems like launchd is likely to be what I want, but there are a few things I could use some help with.

I have figured out how to create the appropriate plist to make the server launch at login and quit at shutdown, and that seems to work fine.

So, I have two questions:

1) Is it possible to set up launchd to not launch the process at login, but to shut it down at logout?

2) I want this all to be controlled by my preference pane. Obviously, it's no trouble to get it to write out the required plist file, but the part I'm not sure about is how to do the equivalent of a "launchctl load" or "launchctl unload" operation. I could exec this, I guess, but I prefer to use a proper C API rather than the exec mechanism whenever I can. I couldn't make heads or tails out of launch.h, I'm afraid.

Thanks in advance,
--Mike
_______________________________________________
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


  • Follow-Ups:
    • Re: Question on using launchd from a C program
      • From: Dave Zarzycki <email@hidden>
  • Prev by Date: Re: GNU-Darwin: missing code in Darwin
  • Next by Date: the Virtual Memory
  • Previous by thread: Re: Compile/Install/Launch DSS
  • Next by thread: Re: Question on using launchd from a C program
  • Index(es):
    • Date
    • Thread