How to list all XPC services/ how to kill them

When an app is running on a Mac, it can add a helper app to its bundle, in the Contents/Library/LoginItems. This app can launch this helper app by running SMLoginItemSetEnabled. This helper app is then always open by macOS after restarts.

What bothers me is that there is no visibility on all these apps. They do not appear in any of the LaunchDaemons/LaunchAgents directories, nor in the System Preferences/Users/LoginItem list.

So I have a few questions :

  • are strictly all apps started in such a way XPC services ?
  • how can I list all such helper apps? Running "launchctl list" seems to list all processes, not simply all such processes, in spite of the help description "Lists information about services". This description therefore appears incorrect to me, am I missing something?
  • How can I prevent these apps from being launched at login/startup? Is "launch unloads" the right way to go about it?

Thanks

Replies

are strictly all apps started in such a way XPC services ?

Service Management login items are closely related to XPC Service but they are not exactly the same.

how can I list all such helper apps?

I believe you need to use the modern launchctl interface. As the launchctl man page makes very clear, list is a legacy command [1].

How can I prevent these apps from being launched at login/startup?

The best way to do that is to call SMLoginItemSetEnabled with false. You have to support that in your app anyway.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] I use these legacy commands all the time because I find them much easier to grok than the new commands. However, when dealing with new (post 10.5) features you have to use new commands.

Thanks for your answer. I missed that list was a legacy command. I'll study further the launchctl man page to understand how to list login items. It's not clear on first read what the right command is.

I wish there was a command line/system wide way to manage services. I understand your point that managing them from the app is good, but I also feel we should be able to control it from the OS, to avoid rogue services/malware, etc.

It's not clear on first read what the right command is.

Yeah, to me too. Hence the footnote in my previous post (-:

I wish there was a command line/system wide way to manage services.

Likewise. We already have a UI for this (System Preferences > Users & Groups > Login Items) it’s just that it’s only wired up to our legacy login items support. I encourage you to file an enhancement request for this support.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"