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
Under unix spawning a new process is generally done by first
fork()
ing the parent process and then replacing the child with a new process image in place throughexec()
.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
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.