Skip to content

Commit

Permalink
extract: exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
whatdoineed2do/Ray committed Jan 23, 2024
1 parent adbfa39 commit 53cb6e4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/extract/imgprextr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ int main(int argc, char* const argv[])
std::streambuf* erros = std::cerr.rdbuf(devnull.rdbuf());

int a = optind;
const int N = argc - a;
while (a < argc)
{
const char* const filename = argv[a++];
Expand Down Expand Up @@ -1024,6 +1025,7 @@ std::for_each(ce->exifData().begin(), ce->exifData().end(), [](const auto& e) {
}

// wait for all threads to finish
unsigned success = 0;
try
{
std::unique_lock<std::mutex> lck(mtx);
Expand All @@ -1033,6 +1035,7 @@ std::for_each(ce->exifData().begin(), ce->exifData().end(), [](const auto& e) {
for (auto& f : futures) {
try {
f.get();
++success;
}
catch (const std::exception& ex) {
std::cerr << argv0 << ": " << ex.what() << std::endl;
Expand All @@ -1044,6 +1047,7 @@ std::for_each(ce->exifData().begin(), ce->exifData().end(), [](const auto& e) {
}

Magick::TerminateMagick();
std::cout << argv0 << ": processed " << success << "/" << N << "\n";

return 0;
return success == N ? 0 : 1;
}

0 comments on commit 53cb6e4

Please sign in to comment.