使用fork / execvp和系统调用之间的区别 [英] Difference between using fork/execvp and system call

查看:1400
本文介绍了使用fork / execvp和系统调用之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用system()执行二进制和使用fork / execvp的组合有什么区别。

What is the difference between using system() to execute a binary and using the combination of fork/execvp.

是否有任何安全性/可移植性/性能差异。

Is there any security/portablility/performance difference.

推荐答案

系统还使用 fork / exec ...组合。如果你执行 fork / exec 你可以并行执行你的运行过程,而 system 是阻塞(包括 wait )。
同样系统执行命令不直接,但通过shell(这使得setuid位的问题)和系统阻塞/忽略某些信号(SIGINT,SIGCHILD,SIGQUIT)。

System also uses a fork/exec... combination. If you do fork/exec yourself you can execute parallel to your running process, while system is blocking (includes the wait). Also system executes the command not direct, but via a shell (which makes problems with setuid bit) and system blocks/ignores certain signals (SIGINT, SIGCHILD, SIGQUIT).

这篇关于使用fork / execvp和系统调用之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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