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
このメッセージを消すにはどうすればよいですか?