简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM