Core MIDI in background service

Hi, I have a background service running as a launch daemon. I need it to connect to a MIDI device. However, MIDIClientCreate() fails with error 268435459. Searching online, I found this corresponds to a kernel error -- MACH_SEND_INVALID_DEST.

When I run the same binary through terminal, it works perfectly.

Is there something I need to add to the launch daemon's plist to enable access to CoreMIDI? The CoreMIDI documentation says that function calls are using IPC to communicate with the CoreMIDI service, which makes sense given the error MACH_SEND_INVALID_DEST. But what I don't understand is why the IPC is apparently failing.

Thanks.
Through some investigation on my computer, I discovered that MIDIService is a user launch agent, so I assume the trip-up was because the root-level launch daemon doesn't have access to user-specific services.

I switched my plist to a user-level launch agent (~/Library/LaunchAgents) and it seems to be working now.
Core MIDI in background service
 
 
Q