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/