C和C ++中使用的exec有哪些不同版本? [英] What are the different versions of exec used for in C and C++?

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

问题描述

这些都是可以在C(和C ++)中使用的exec版本。

These are all the versions of exec that can be used in C (and C++)

execl
execle
execlp
execv
execve
execvp

这是什么他们之间的区别?

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

推荐答案

区别是以下各项的组合:

The differences are combinations of:


  1. L vs V :是否要将参数作为


  • L :调用中的各个参数(可变参数列表): 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()

当要发送到执行过程的参数数量可变时,数组格式很有用-如前所述,因此您不能在函数调用中放入固定数量的参数。

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 :带有 e的版本最后让你额外通过一组char *,它们是在执行程序启动之前添加到产生的流程环境中的一组字符串。确实是传递参数的另一种方法。

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'的版本使用环境变量 PATH
搜索要执行的可执行文件。如果没有可执行文件的版本不在当前工作目录中,则没有'p'的版本必须在该文件名之前添加绝对或相对文件路径。

P: The versions with 'p' in there use the environment variable PATH 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.

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

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