What does launchctl unload actually do?

When running launchctl unload some.plist, what is this command translated to specifically, in terms of UNIX commands, etc.

There is nothing in .plist files that specifies any "command line to run when the user specifies unload", so does macOS simply send a kill signal to the process? Or what does it do?


SIGTERM

launchd's unload command sends a SIGTERM signal to the associated job's child processes.

Detached Processes

If a process launched by a launchd job has detached from it's parent process, then unload will not affect that process. This is often the case for daemonised processes.

Original Source Code

You can download and inspect the original launchd source code. launchd has since been rewritten and is proprietary to Apple but the original documents the intended behaviour on unload.


To best answer this question we can look at two things: UNIX commands and what is in a .plist.

Starting out with a .plist, the following code is usually there

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>CFBundleExecutable</key>
  <string>someApplication</string>
</dict>
</plist>

The CFBundleExecutable identifies the name of the bundle’s main executable file. For an app, this is the app executable. For a loadable bundle, it is the binary that will be loaded dynamically by the bundle.

So typing launchctl unload some.plist will tell MacOS the key to locate the bundle’s executable file and 'unload' it or essentially kill it from the system. This is telling it at an application level.

When using a UNIX command such as kill <PID> it is in reference to a specific process.

Looking at what is a Process vs Application here is good reading


You can read further into what is in .plists and how they work over at Apple