villintehaspam
villintehaspam

Reputation: 8754

execve from a Mac OS X launchd daemon

Is it possible to use execve from a launchd daemon? My process that I would like to make into a daemon launches several child processes using fork() followed by execve, but the documentation for creating launchd daemons states that "calling fork followed by exec" is not ok. Does this mean that I cannot create child processes from a daemon?

Upvotes: 4

Views: 1784

Answers (1)

DarkDust
DarkDust

Reputation: 92354

AFAIK, you can fork and exec just fine. The critical point is this one: "You must not fork your process and have the parent process exit." Thing is, launchd "watches over" your service. If your service exits, it gets restarted. That means it may not daemonize, either (with daemonize I mean the classical spawn a new process, create a new process group, exit parent process, subprocess lives on scheme).

I guess you should make sure to kill/quit your subprocesses before you exit the main process, just to not litter the environment.

Upvotes: 5

Related Questions