diff --git a/src/main/main.cc b/src/main/main.cc index 4382d89e9..a26e8b56a 100644 --- a/src/main/main.cc +++ b/src/main/main.cc @@ -35,6 +35,7 @@ #endif #include +#include #include #include #include @@ -145,13 +146,19 @@ int main(int argc, char** argv) if (!boost::filesystem::exists(p)) { std::cout << "The path " - << FLAGS_log_dir - << " does not exist, attempting to create it" - << std::endl; - boost::filesystem::create_directory(p); + << FLAGS_log_dir + << " does not exist, attempting to create it." + << std::endl; + boost::system::error_code ec; + boost::filesystem::create_directory(p, ec); + if(ec != 0) + { + std::cout << "Could not create the " << FLAGS_log_dir << " folder. GNSS-SDR program ended." << std::endl; + google::ShutDownCommandLineFlags(); + std::exit(0); + } } - std::cout << "Logging with be done at " - << FLAGS_log_dir << std::endl; + std::cout << "Logging with be done at " << FLAGS_log_dir << std::endl; } std::unique_ptr control_thread(new ControlThread()); @@ -169,6 +176,10 @@ int main(int argc, char** argv) { LOG(FATAL) << "Boost exception: " << boost::diagnostic_information(e); } + catch( boost::lock_error & le ) + { + LOG(FATAL) << "Lock error exception: " << boost::diagnostic_information(le); + } catch(std::exception const& ex) { LOG(FATAL) << "STD exception: " << ex.what();