popen noly redirect the STDIN and STDOUT, use
popen("ls -l 2>&1 ", "r");
will get the result in stderr. It's useful when the command execution encounter an error.
本文介绍如何利用popen函数重定向标准输入(STDIN)和标准输出(STDOUT),通过将输出重定向到标准错误(stderr)来获取命令执行过程中产生的错误信息,这对于调试和错误处理非常有用。
popen noly redirect the STDIN and STDOUT, use
popen("ls -l 2>&1 ", "r");
will get the result in stderr. It's useful when the command execution encounter an error.
413

被折叠的 条评论
为什么被折叠?