系统"&之间的差异QUOT;和" EXEC"在Linux呢? [英] Difference between "system" and "exec" in Linux?
问题描述
什么是系统
和 EXEC
命令族之间的区别?特别是我想知道这其中的一个创建子进程来工作?
What is the difference between system
and exec
family commands? Especially I want to know which one of them creates child process to work?
推荐答案
系统()
召唤出 SH
处理您的命令行,这样你就可以得到通配符扩展等执行exec()
和它的朋友请更换一个新的进程映像当前的进程映像。
system()
calls out to sh
to handle your command line, so you can get wildcard expansion, etc. exec()
and its friends replace the current process image with a new process image.
使用系统()
,你的程序继续运行,你回来你调用的外部命令的一些状态。随着执行exec()
,你的进程抹杀。
With system()
, your program continues running and you get back some status about the external command you called. With exec()
, your process is obliterated.
在一般情况下,我想你能想到的系统()
作为更高层次的接口。你可以重复使用一些组合自己的功能叉()
,执行exec()
和等待()
。
In general, I guess you could think of system()
as a higher-level interface. You could duplicate its functionality yourself using some combination fork()
, exec()
, and wait()
.
要回答你的最后一个问题,系统()
导致创建一个子进程,并在执行exec()
家庭没有。您需要使用叉()
为
To answer your final question, system()
causes a child process to be created, and the exec()
family do not. You would need to use fork()
for that.
这篇关于系统"&之间的差异QUOT;和" EXEC"在Linux呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!