我一直在关注关于C编程的在线教程,代码使用的是Apache APR库。它使用apr_proc_t结构来执行外部应用程序。我对这个函数感到困惑,有没有人能解释一下这个函数的含义:
apr_status_t apr_procattr_cmdtype_set ( apr_procattr_t * attr,
apr_cmdtype_e cmd
)
Set what type of command the child process will call.
Parameters:
attr The procattr we care about.
cmd The type of command. One of:
APR_SHELLCMD -- Anything that the shell can handle
APR_PROGRAM -- Executable program (default)
APR_PROGRAM_ENV -- Executable program, copy environment
APR_PROGRAM_PATH -- Executable program on PATH, copy env发布于 2012-07-27 05:16:04
apr_procattr_cmdtype_set函数用于告诉APR您希望如何执行外部命令,它可能只是设置一个内部标志并做一些记账工作。
让我们来看一下enum apr_cmdtype_e
APR_SHELLCMD
使用shell调用程序
APR_PROGRAM
直接调用程序,不复制环境
APR_PROGRAM_ENV
调用程序,复制我们的环境
APR_PROGRAM_PATH
在PATH上查找程序,使用我们的环境
APR_SHELLCMD_ENV
使用shell调用程序,复制我们的环境
第一个和最后一个选项(APR_SHELLCMD和APR_SHELLCMD_ENV)说明“使用system的可移植版本”(无论是否将当前环境变量复制到新进程)。其他的只是Unix fork/exec对的变体,带有选择要使用的exec系列函数的标志。
https://stackoverflow.com/questions/11662957
复制相似问题