在不继承文件/端口的OSX/Unix上启动子进程 [英] Launch a child process on OSX/Unix that doesn't inherit files/ports

查看:122
本文介绍了在不继承文件/端口的OSX/Unix上启动子进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在OS X上启动一个子进程,以使该子进程不继承当前进程的打开文件/端口.

I want to launch a child process on OS X such that the child process does not inherit the current process's open files/ports.

关于如何实现此目标的任何建议?我可以使用system()函数调用的Shell命令也可以工作-我只是不知道有一个好的Shell命令可以启用此功能.

Any suggestions on how to accomplish this? Shell commands that I can invoke using the system() function would work too - I just don't know of a good shell command that enables this.

谢谢!

推荐答案

经过一些试验,我发现Mac上的"open" shell命令创建了一个不继承父文件/端口的进程.调用"open foo.app"作为系统函数的参数可以达到目的.当然,这仅是mac.对于Unix,这里建议的其他方法之一很有道理.

After some experimenting, I found that the 'open' shell command on Mac creates a process that does not inherit the parents files/ports. Invoking 'open foo.app' as arguments to the system function does the trick. Of course, this is mac only. For Unix, one of the other approaches suggested here makes a lot of sense.

这篇关于在不继承文件/端口的OSX/Unix上启动子进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆