我正在使用 system() 从我的应用程序运行一些 Unix 命令,代码如下:
std::stringstream command;
command << "rm -rf /some/directory";
int rmResult = system(command.str().c_str());
if (rmResult != 0) {
clog << "Error: Failed to remove old output directory '" << command.str()
<< "' (" << errno << ") " << strerror(errno) << ".\n";
throw;
}
但是,虽然 rmResult 为零并且 rm 有效,但我在控制台中收到此错误:
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
我做错了什么,我怎样才能让这个消息消失?