发射过程中的PID污染 [英] PID Pollution by launching process
问题描述
在nix / mac上,如果我用nsiProcess run或runAsync启动一个进程,启动进程的PID将进入启动进程的文件(如锁定文件)等。
<这个gif显示我有一个配置文件。我在文件上做了lsof,它显示了一个pid。然后,我启动第二个配置文件,现在显示其中一个parentlock文件现在有多个pid。任何想法如何避免这种污染?通过nsiprocess或jsctypes / libc方法,我可以使用?
哦,这是gif显示我的screencast,它循环一次,所以如果你想重复只是一个简单的页面刷新
进入父进程,然后用新的进程映像替换子进程 / em>通过 分叉会导致新进程继承父进程中的所有文件描述符。然后它可能在调用 On nix/mac if i launch a process with nsiProcess run or runAsync, the launching process PID gets onto the files (like locked files) etc of the launching process. This gif shows i have one profile. I do lsof on the parentlock file, it shows one pid. I then launch a second profile, it now shows that one of the parentlock files now has multiple pid. Any ideas on how to avoid this pid pollution? via nsiprocess or jsctypes/libc methods I can use? Oh here's the gif showing my screencast, it loops once, so if u want to repeat just a simply page refresh http://i.imgur.com/OsuGbqB.gif Under unix spawning a new process is generally done by first Forking causes the new process to inherit - among many other things - all file descriptors from the parent process. It may then shed some of them on calling 这篇关于发射过程中的PID污染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! exec()
。
exec()
时释放其中的一些,但默认情况下不会这样做。请参阅这个答案如何标记文件描述符,
$ b
exec()$ c $最后开始你想要的孩子进程。
fork()
ing the parent process and then replacing the child with a new process image in place through exec()
.exec()
, but does not do so by default. See this SO answer how to mark file descriptors for close-on-exec.
exec()
to finally start the child process you actually wanted.