libcryfs/test/cpp-utils/process/exit_status.cpp

22 lines
499 B
C++
Raw Normal View History

// This is a small executable that exits with the exit status in its first argument and before exiting prints all other arguments, each on a separate line.
2018-07-09 04:34:08 +02:00
#include <iostream>
2018-08-08 03:04:32 +02:00
#include <cstdlib>
2018-07-09 04:34:08 +02:00
int main(int argc, char *argv[])
{
if (argc < 2)
{
2018-07-09 04:34:08 +02:00
std::cerr << "Wrong number of arguments" << std::endl;
2018-08-08 03:04:32 +02:00
std::abort();
2018-07-09 04:34:08 +02:00
}
for (int i = 2; i < argc; ++i)
{
std::cout << argv[i] << "\n";
}
2018-07-09 04:34:08 +02:00
const int exit_status = static_cast<int>(std::strtol(argv[1], nullptr, 10));
2018-07-09 04:34:08 +02:00
return exit_status;
}