I am writing an application that uses a library that will not work when the application is run as a launchd daemon. There is a bug in the library where it will throw a bus error when used from a daemon. (See my stack overflow post: https://stackoverflow.com/questions/20599283/signal-10-sigbus-in-c-library-when-running-application-as-launchd-daemon)

Everything works fine however, when I run the application normally. I am wondering if there are any alternatives to launchd I should consider. The application needs to start on boot and run even when no users are logged in. It would also be preferable that the application is relaunched if it crashes, but I can live without that if I have to.

I've done some research on startup items, but since they are deprecated, I am wary that Apple will just remove the functionality some day.


No. You'll very probably hit the exact same problem with any alternative as you are getting here.

Without going into too much detail of what's obvious from the stack trace, which is StackOverflow territory:

The problem is almost certainly down to the different process state that a daemon has, compared to a program that you run from a desktop or a shell. Environment variables, the current directory, resource limits, open file handles, controlling terminals, root directory, and even supplementary groups can be — and for most of those are — different in a dæmon process run from a dæmon supervisor from a process invoked in a login session.

Your problem could be down to any difference between the twain. (My educated guess is environment variables, because of what's in the stack trace.) But these differences are inherent in dæmon supervisors. Executing dæmons with fixed, determinable, process states is part of their design. If you substitute another dæmon supervisor, you'll still get a controlled process state that doesn't match that of processes run in your login session.

You shouldn't be considering alternatives to launchd. You should be looking at your plist and adjusting it to set up the right stuff (probably environment variables, as I said) that your ODBC driver expects to have available to it. And you should be reading whatever 4D doco there is. ☺

  • JdeBP was actually able to solve the original problem, you can see the answer here
    – Eric Milas
    Dec 20 '13 at 0:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.