Skip to content

Commit

Permalink
Explicitly ignore return values of setting signal and exit handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
msimberg committed Nov 8, 2023
1 parent 8006980 commit 84dd01d
Show file tree
Hide file tree
Showing 26 changed files with 77 additions and 24 deletions.
6 changes: 3 additions & 3 deletions libs/pika/init_runtime/src/init_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,10 @@ namespace pika {
freebsd_environ = environ;
#endif
// set a handler for std::abort
std::signal(SIGABRT, pika::detail::on_abort);
std::atexit(pika::detail::on_exit);
[[maybe_unused]] auto signal_handler = std::signal(SIGABRT, pika::detail::on_abort);
[[maybe_unused]] auto exit_result = std::atexit(pika::detail::on_exit);
#if defined(PIKA_HAVE_CXX11_STD_QUICK_EXIT)
std::at_quick_exit(pika::detail::on_exit);
[[maybe_unused]] auto quick_exit_result = std::at_quick_exit(pika::detail::on_exit);
#endif
return run_or_start(f, argc, argv, params, blocking);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <pika/init.hpp>
#include <pika/testing.hpp>

#include <cstdlib>

char const* argv[] = {"command_line_argument_test",
// We need only one thread, this argument should be gone in pika_main
"--pika:threads=1", "nx=1", "ny=1=5"};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <pika/init.hpp>
#include <pika/testing.hpp>

#include <cstdlib>

bool invoked_main = false;

int my_pika_main(int argc, char**)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# include <cmath>
# include <cstddef>
# include <cstdint>
# include <cstdlib>
# include <iostream>
# include <memory>
# include <set>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# include <cmath>
# include <cstddef>
# include <cstdint>
# include <cstdlib>
# include <iostream>
# include <memory>
# include <set>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
//[body
#include <pika/init.hpp>

#include <cstdlib>

int pika_main()
{
pika::finalize();
Expand Down
4 changes: 3 additions & 1 deletion libs/pika/synchronization/tests/unit/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <atomic>
#include <cstddef>
#include <cstdlib>
#include <functional>
#include <string>
#include <utility>
Expand Down Expand Up @@ -84,7 +85,8 @@ int pika_main(variables_map& vm)
}

// Initiate shutdown of the runtime system.
return finalize();
finalize();
return EXIT_SUCCESS;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down
5 changes: 3 additions & 2 deletions libs/pika/synchronization/tests/unit/latch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <atomic>
#include <cstddef>
#include <cstdlib>
#include <functional>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -109,8 +110,8 @@ int pika_main()
PIKA_TEST_EQ(num_threads.load(), NUM_THREADS);
}

PIKA_TEST_EQ(pika::finalize(), 0);
return 0;
pika::finalize();
return EXIT_SUCCESS;
}

int main(int argc, char* argv[])
Expand Down
4 changes: 3 additions & 1 deletion tests/performance/local/async_overheads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -119,7 +120,8 @@ int pika_main(pika::program_options::variables_map& vm)
pika::util::print_cdash_timing(
"AsyncSpeedup", sequential_time_per_task / hierarchical_time_per_task);

return pika::finalize();
pika::finalize();
return EXIT_SUCCESS;
}

int main(int argc, char* argv[])
Expand Down
4 changes: 3 additions & 1 deletion tests/performance/local/coroutines_call_overhead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <chrono>
#include <cstdint>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <random>
Expand Down Expand Up @@ -163,7 +164,8 @@ int pika_main(variables_map& vm)
print_results(total_elapsed);
}

return pika::finalize();
pika::finalize();
return EXIT_SUCCESS;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 3 additions & 1 deletion tests/performance/local/future_overhead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <stdexcept>
Expand Down Expand Up @@ -385,7 +386,8 @@ int pika_main(variables_map& vm)
}
}

return pika::finalize();
pika::finalize();
return EXIT_SUCCESS;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 3 additions & 1 deletion tests/performance/local/future_overhead_report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <array>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <string>
#include <type_traits>

Expand Down Expand Up @@ -140,7 +141,8 @@ int pika_main(variables_map& vm)
if (test_all) { measure_function_create_thread_hierarchical_placement(count, repetitions); }
}

return pika::finalize();
pika::finalize();
return EXIT_SUCCESS;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 3 additions & 1 deletion tests/performance/local/htts_v2/htts2_pika.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <atomic>
#include <chrono>
#include <cstdint>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <string>
Expand Down Expand Up @@ -63,7 +64,8 @@ struct pika_driver : htts2::driver
results_type results = kernel();
print_results(results);

return pika::finalize();
pika::finalize();
return EXIT_SUCCESS;
}

pika::threads::detail::thread_result_type payload_thread_function(
Expand Down
7 changes: 6 additions & 1 deletion tests/performance/local/start_stop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@

#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <iostream>

namespace ex = pika::execution::experimental;

int pika_main() { return pika::finalize(); }
int pika_main()
{
pika::finalize();
return EXIT_SUCCESS;
}

int main(int argc, char** argv)
{
Expand Down
4 changes: 3 additions & 1 deletion tests/performance/local/timed_task_spawn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <chrono>
#include <condition_variable>
#include <cstdint>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iostream>
Expand Down Expand Up @@ -458,7 +459,8 @@ int pika_main(variables_map& vm)
// Force termination of all suspended tasks.
pika::get_runtime().get_thread_manager().abort_all_suspended_threads();
}
return pika::finalize();
pika::finalize();
return EXIT_SUCCESS;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down
5 changes: 4 additions & 1 deletion tests/regressions/multiple_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
#include <pika/init.hpp>
#include <pika/testing.hpp>

#include <cstdlib>

int invoked_init = 0;

int pika_main()
{
++invoked_init;
return pika::finalize();
pika::finalize();
return EXIT_SUCCESS;
}

int main(int argc, char** argv)
Expand Down
4 changes: 3 additions & 1 deletion tests/regressions/multiple_init_2918.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
#include <pika/init.hpp>
#include <pika/testing.hpp>

#include <cstdlib>
#include <string>

std::string expected;

int pika_init_test(std::string s, int, char**)
{
PIKA_TEST_EQ(s, expected);
return pika::finalize();
pika::finalize();
return EXIT_SUCCESS;
}

int main(int argc, char* argv[])
Expand Down
4 changes: 3 additions & 1 deletion tests/regressions/stack_size_config_4543.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <pika/thread.hpp>

#include <chrono>
#include <cstdlib>

// This test ensures that thread creation uses the correct stack sizes. We
// slightly change all the stack sizes in the configuration to catch problems
Expand All @@ -21,7 +22,8 @@ int pika_main()
pika::thread t([]() {});
t.join();

return pika::finalize();
pika::finalize();
return EXIT_SUCCESS;
}

int main(int argc, char** argv)
Expand Down
4 changes: 3 additions & 1 deletion tests/regressions/threads/block_os_threads_1036.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <atomic>
#include <cstdint>
#include <cstdlib>
#include <functional>
#include <memory>
#include <string>
Expand Down Expand Up @@ -107,7 +108,8 @@ int pika_main()
exit_barrier.arrive_and_wait();
}

return pika::finalize();
pika::finalize();
return EXIT_SUCCESS;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down
5 changes: 4 additions & 1 deletion tests/regressions/threads/stackless_self_4155.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <pika/testing.hpp>
#include <pika/thread.hpp>

#include <cstdlib>

void stackless_thread()
{
PIKA_TEST_NEQ(pika::threads::detail::get_self_id(), pika::threads::detail::invalid_thread_id);
Expand All @@ -20,7 +22,8 @@ int pika_main()
pika::execution::thread_priority::default_, pika::execution::thread_schedule_hint(),
pika::execution::thread_stacksize::nostack);
pika::threads::detail::register_work(data);
return pika::finalize();
pika::finalize();
return EXIT_SUCCESS;
}

int main(int argc, char** argv)
Expand Down
4 changes: 3 additions & 1 deletion tests/regressions/threads/thread_data_1111.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <pika/thread.hpp>

#include <cstddef>
#include <cstdlib>
#include <iostream>
#include <memory>

Expand Down Expand Up @@ -39,7 +40,8 @@ int pika_main()

PIKA_TEST_EQ(get_thread_num(), 42);

return pika::finalize();
pika::finalize();
return EXIT_SUCCESS;
}

int main(int argc, char** argv)
Expand Down
4 changes: 3 additions & 1 deletion tests/regressions/threads/thread_suspend_duration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <chrono>
#include <cstddef>
#include <cstdlib>
#include <functional>
#include <string>
#include <vector>
Expand Down Expand Up @@ -72,7 +73,8 @@ int pika_main(variables_map& vm)
}

// Initiate shutdown of the runtime system.
return pika::finalize();
pika::finalize();
return EXIT_SUCCESS;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 3 additions & 1 deletion tests/regressions/threads/thread_suspend_pending.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <pika/thread.hpp>

#include <cstddef>
#include <cstdlib>
#include <functional>
#include <string>
#include <vector>
Expand Down Expand Up @@ -66,7 +67,8 @@ int pika_main(variables_map& vm)
}

// Initiate shutdown of the runtime system.
return pika::finalize();
pika::finalize();
return EXIT_SUCCESS;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 3 additions & 1 deletion tests/regressions/threads/threads_all_1422.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <pika/thread.hpp>

#include <cstddef>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
Expand All @@ -28,7 +29,8 @@ int pika_main()

PIKA_TEST_EQ(num_cores, os_threads);

return pika::finalize();
pika::finalize();
return EXIT_SUCCESS;
}

int main(int argc, char** argv)
Expand Down
5 changes: 4 additions & 1 deletion tests/regressions/unhandled_exception_582.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
#include <pika/init.hpp>
#include <pika/testing.hpp>

#include <cstdlib>

int pika_main()
{
PIKA_THROW_EXCEPTION(pika::error::invalid_status, "pika_main", "testing");
return pika::finalize();
pika::finalize();
return EXIT_SUCCESS;
}

int main(int argc, char** argv)
Expand Down
Loading

0 comments on commit 84dd01d

Please sign in to comment.