I'm looking for a supported way to launch a signed AppKit application for user interaction from a local Python supervisor, while retaining reliable supervision of the exact launched instance.
Environment
- Apple M3 MacBook Air, macOS 14.5, build 23F79.
- arm64 app built with Command Line Tools clang and the macOS 14.5 SDK, targeting macOS 14.0.
- AppKit/Foundation with embedded CPython 3.12.
- Apple Development signing, hardened runtime and strict signature checks passed.
Current launch and activation sequence
The supervisor directly launches the bundle executable with Popen: a fixed argument, empty environment, new process session, disconnected stdin, and an anonymous stdout pipe carrying fixed, nonsecret startup markers. There is no LaunchServices foreground handoff.
On its main thread, the app initializes NSApplication, confirms Regular activation policy, calls finishLaunching and activateIgnoringOtherApps:YES, then waits for isActive. Event-retrieval waits are capped at 20 ms; event dispatch itself may take longer. Existing timeout supervision remains active.
Our activation guard is two seconds from the readiness routine's start, subject to the remaining native timer. A separate overall test budget is 300 seconds from operator readiness, before preflight.
Observed result
The latest test exited with code 1 after approximately 2.57 seconds. The validated markers were:
absence.begin → absence.absent → fields.begin → ui.begin
→ app.shared.begin → app.shared.ready
→ policy.before → policy.already_regular → policy.postcondition
→ launch.finish.begin → launch.finish.ready
→ activation.requested → activation.wait.begin
→ stop.activation.timeout
The final recorded state was:
main=1 app=1 active=0 policy=0 window=0 visible=-1 key=-1
The app stopped before constructing the dialog. Adding event processing did not resolve activation. We have not established why activation failed or which events were delivered. The two-second deadline is our guard, not an asserted macOS activation guarantee.
Questions
- What supported launch and activation approach should this supervisor use for a foreground, interactive AppKit app?
- Can this direct-executable design be corrected narrowly, or should launching move to LaunchServices with a different communication and supervision arrangement?
- With the recommended approach, how should the supervisor identify the exact launched instance, receive startup status, enforce bounded termination, and establish that the process has exited before cleanup?
We reviewed a simple foreground-launch substitution, but it did not preserve our existing marker pipe and authoritative exit/reap evidence. That is a limitation of our proposed adaptation, not a claim that Apple's APIs cannot support these outcomes.
The essential requirements are exact-instance identification, nonsecret status reporting, bounded termination and verified cleanup. An anonymous pipe and direct-child waiting are current implementation choices, not requirements in themselves.
The key question here is fidelity. You’re running the app as a child process. That’s not how apps are normally launched, and it can definitely affect the app’s behaviour [1]. So you have a trade-off to make:
- Run the app as a child process, which gives you more control but means that the app won’t necessarily behave normally.
- Run the app using
NSWorkspace, which gives you less control but means that the app runs much as it would if you ran it from the Finder.
Note that NSWorkspace will give you back an NSRunningApplication instance, and from that you can get the pid. Annoyingly, there’s no way to get an audit token from it but, as the documentation for processIdentifier explains, you can use isEqual: to check for identity in a way that guards against pid reuse.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] I’ve seen this crop up in a number of different ways:
- The app uses a lot of file descriptors, and thus bumps into the file descriptor limit in one case or the other.
- The app relies on the current working directory.
- The app relies on
std{in,out,err}.