c - C 和 Perl 中的 system() 有什么区别?

标签 c perl process system

system() 函数将从 C 和 Perl 脚本启动一个新进程。

在错误代码的表示方面,C 中 system() 调用的进程与 Perl 脚本调用的进程之间到底有什么区别?

最佳答案

一些研究提出:

The return value is the exit status of the program as returned by the wait call. To get the actual exit value, shift right by eight (see below). See also "exec". This is not what you want to use to capture the output from a command, for that you should use merely backticks or qx//, as described in "STRING" in perlop. Return value of -1 indicates a failure to start the program or an error of the wait(2) system call (inspect $! for the reason).

wait 的文档说:

Behaves like the wait(2) system call on your system: it waits for a child process to terminate and returns the pid of the deceased process, or -1 if there are no child processes. The status is returned in $? and ${^CHILD_ERROR_NATIVE} . Note that a return value of -1 could mean that child processes are being automatically reaped, as described in perlipc.


资料来源:这取自 perldoc .这是一个 tutorial on system在 Perl 中。

关于c - C 和 Perl 中的 system() 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1845038/

相关文章:

c - 为什么 abs(1.5) 在 ideone.com 上返回 0 而不是 1 或 2?

c - 对当前堆栈进行校验和

c - R包: breakpoint setup for C function with gdb in Debian (Testing)

xml - 清除子处理程序中的 XML Twig

java - 如何用java读取command.com的输出

linux - 如何确保进程被杀死? (使用 kill 命令)

c - 2D 到 3D 平行投影

perl - 为用 perl 编写的应用程序构建 .deb 安装文件的常用工具是什么?

perl - 为什么 IPC::Run3 在 Apache 环境中无法捕获任何标准输出?

java - Windows 8 - 退出 Java 应用程序/进程而不停留在后台