什么是EXEC在C ++中使用的不同版本? [英] What are the different versions of exec used for in C++?

查看:138
本文介绍了什么是EXEC在C ++中使用的不同版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是可以在C ++

execl
execle
execlp
execv
execvp
execvP

有什么区别?你怎么知道用哪一个呢?

What's the difference? How do you know which one to use?

推荐答案

的区别是的组合:


  1. L比V :您是否想传递参数给exec'ed程序作为

  1. L vs V: whether you want to pass the parameters to the exec'ed program as


  • :在调用(可变参数列表)个别参数: EXECL() execle() execlp() execlpe()

  • V :作为一个字符数组* execv()的execve() execvp() execvpe()

  • L: individual parameters in the call (variable argument list): execl(), execle(), execlp(), and execlpe()
  • V: as an array of char* execv(), execve(), execvp(), and execvpe()

当的要被发送到exec'ed过程参数的数目是可变的阵列格式是很有用的 - 如在事先不知道,所以不能把一个固定数目的参数的函数呼叫。

The array format is useful when the number of parameters that are to be sent to the exec'ed process are variable -- as in not known in advance, so you can't put in a fixed number of parameters in a function call.

电子:用在最后一个'e'的版本,让你额外传递的char *数组是一组EXEC之前加入到生成的进程环境字符串编辑程序启动。然而传递参数,真正的另一种方式。

E: The versions with an 'e' at the end let you additionally pass an array of char* that are a set of strings added to the spawned processes environment before the exec'ed program launches. Yet another way of passing parameters, really.

P :在那里有P的版本使用环境路径变量
搜索名为执行可执行文件。没有P的版本需要的绝对或相对文件路径为prepended可执行的文件名,如果它不在当前工作目录。

P: The versions with 'p' in there use the environment path variable to search for the executable file named to execute. The versions without the 'p' require an absolute or relative file path to be prepended to the filename of the executable if it is not in the current working directory.

这篇关于什么是EXEC在C ++中使用的不同版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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