Question

I am using system() to run some Unix commands from my application with code like the following:

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;
}

However, while rmResult is zero and the rm works, I get this error in the console:

shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

What am I doing wrong, and how can I get this message to go away?

Was it helpful?

Solution

Apparently, this was due to having a directory that is now gone on my pushd stack, even though it was not the current working directory. Cleaning out my stack of the now gone directory, caused the messages to go away.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top