简体   繁体   English

从Mac OS X launchd守护进程中执行

[英]execve from a Mac OS X launchd daemon

Is it possible to use execve from a launchd daemon? 是否可以使用launchd守护进程中的execve 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. 我想要进入守护进程的进程使用fork()后跟execve启动几个子进程,但是创建launchd守护进程文档声明“调用fork后跟exec”是不行的。 Does this mean that I cannot create child processes from a daemon? 这是否意味着我无法从守护进程创建子进程?

AFAIK, you can fork and exec just fine. AFAIK,你可以分叉和执行就好了。 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). 这意味着它也可能没有守护进程(使用daemonize我的意思是经典产生一个新进程,创建一个新进程组,退出父进程,子进程依赖于 scheme)。

I guess you should make sure to kill/quit your subprocesses before you exit the main process, just to not litter the environment. 我想你应该确保在退出主进程之前杀死/退出你的子进程,只是为了不乱丢环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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