Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wish to load and run a Lisp program in CCL in the background automatically when my Mac (OS 10.9) boots. I have a launchd plist that I've saved to /Library/LaunchDaemons,

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">

When I call

launchctl load /Library/LaunchDaemons/com.icecreamcomputer.plist

from the terminal, I can see in top that dx86cl runs for a few seconds, then goes away. Afterward launchd lists the job as having exited. However, if I call

sudo /Applications/ccl/./dx86cl -l /Users/frank/Documents/Lisp/ice-cream-computer/ice-cream-computer.lisp

from the terminal, my program starts up and stays running no problem. What could be causing my launchd job to quit immediately after starting?

Here are entries from /var/log/system.log:

Apr 15 10:01:55 sudo[34963]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/Applications/ccl/./dx86cl -l /Users/frank/Documents/Lisp/ice-cream-computer/ice-cream-computer.lisp
Apr 15 10:01:58 frynseytv[1] (com.icecreamcomputer): Throttling respawn: Will start in 8 seconds
Apr 15 10:02:00 frynseytv[306] (com.icecreamcomputer[34965]): open("/var/log/icecreamcomputer.log", ...): 13: Permission denied
Apr 15 10:02:02 frynseytv[306] (com.icecreamcomputer): Throttling respawn: Will start in 8 seconds

Apparently it didn't have permission to open a log called "/var/log/icecreamcomputer.log," and indeed no such file or directory exists. Although that seems odd because root/wheel owns /var/log/icecreamcomputer.log, and root runs launchd and the other processes launchd launches, doesn't it? Here's an excerpt from /var/log/icecreamcomputer.log. It shows what normally prints to stdout when icecreamcomputer.lisp loads. What it lacks is logged http server activity, like receiving and fulfilling requests.

Welcome to Clozure Common Lisp Version 1.9-r15759  (DarwinX8664)!
==== quicklisp quickstart loaded ====

To continue with installation, evaluate: (quicklisp-quickstart:install)

For installation options, evaluate: (quicklisp-quickstart:help)

To load "hunchentoot":
Load 1 ASDF system:
; Loading "hunchentoot"

Actually when I tail -f /var/log/icecreamcomputer.log, it continues its cycles of throttling respawns and saying that it fails to write to its log even after I call launchctl unload /Library/LaunchDaemons/com.icecreamcomputer.plist. It only stopped cycling upon server reboot. What gives?

After the restart, I attempted to load the daemon again. No error messages, but launchctl list shows the process has exited, and tailing icecreamcomputer.log showed no activity while I loaded the daemon's plist.

share|improve this question
What is in your log files? – Jenny D Apr 15 '14 at 7:16
Oh yes, good question, thank you. I've added system.log entries to the post. – fpt Apr 15 '14 at 14:08
Why do you have sudo in your launchd plist? You aren't actually switching to another user! – Michael Hampton Apr 15 '14 at 18:19
Sudo was there at one point because I was grasping at straws, but I get the same behavior regardless. – fpt Apr 15 '14 at 23:04

It sounds like your LISP programming is violating launchd's daemon requirements:

"You must not daemonize your process. This includes calling the daemon function, calling fork followed by exec, or calling fork followed by exit. If you do, launchd thinks your process has died. Depending on your property list key settings, launchd will either keep trying to relaunch your process until it gives up (with a “respawning too fast” error message) or will be unable to restart it if it really does die.”


To understand launchd better — particularly for the plist syntax — I recommend writing a hello world script with an infinity loop using the logger(1) command to write to sylog ever ~5 seconds. Make the script work in the foreground and the background to see the difference. Also, use plutil(1) to double check for easily overlooked syntax errors.

Apple’s launchd jobs in /System/Library/LaunchDaemons are also an excellent reference. Note that apache one in particular, which uses:

/usr/sbin/httpd -D string>FOREGROUND

To solve launchd's daemon requirement.

Good luck!

share|improve this answer
Thanks! It could be that one of the library packages my program loads does such a thing. The simpler hello world program I'd already tried worked fine. Ultimately I got what I wanted by moving the program to a Raspbian Linux machine and launching it with an init script. Your suggestion and my experience with the two systems implies that launchd, and Mac OS X, is ill-suited to launching things like webservers at startup. – fpt Apr 22 '14 at 14:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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