33 |
33 |
34 using namespace relpipe::cli; |
34 using namespace relpipe::cli; |
35 using namespace relpipe::reader; |
35 using namespace relpipe::reader; |
36 using namespace relpipe::out::jack; |
36 using namespace relpipe::out::jack; |
37 |
37 |
|
38 static std::shared_ptr<JackHandler> jackHandler = nullptr; |
|
39 |
|
40 void finish(int sig) { |
|
41 if (jackHandler) jackHandler->finish(sig); |
|
42 } |
|
43 |
38 int main(int argc, char**argv) { |
44 int main(int argc, char**argv) { |
39 CLI cli(argc, argv); |
45 CLI cli(argc, argv); |
40 CLI::untieStdIO(); |
46 CLI::untieStdIO(); |
41 |
47 |
42 int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
48 int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
43 |
49 |
44 try { |
50 try { |
|
51 signal(SIGHUP, finish); |
|
52 signal(SIGINT, finish); |
45 CLIParser cliParser; |
53 CLIParser cliParser; |
46 Configuration configuration = cliParser.parse(cli.arguments()); |
54 Configuration configuration = cliParser.parse(cli.arguments()); |
47 std::shared_ptr<RelationalReader> reader(Factory::create(std::cin)); |
55 std::shared_ptr<RelationalReader> reader(Factory::create(std::cin)); |
48 JackHandler handler(configuration); |
56 jackHandler.reset(new JackHandler(configuration)); |
49 reader->addHandler(&handler); |
57 reader->addHandler(jackHandler.get()); |
50 reader->process(); |
58 reader->process(); |
51 |
59 |
52 resultCode = CLI::EXIT_CODE_SUCCESS; |
60 resultCode = CLI::EXIT_CODE_SUCCESS; |
53 |
61 |
54 } catch (RelpipeCLIException e) { |
62 } catch (RelpipeCLIException e) { |