0

我正在使用 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

我做错了什么,我怎样才能让这个消息消失?

4

1 回答 1

2

显然,这是因为有一个目录现在不在我的 pushd 堆栈上,即使它不是当前的工作目录。清理我现在消失的目录堆栈,导致消息消失。

于 2011-01-04T03:05:34.750 回答