Re: [Quickfix-developers] ctrl-c , sleep and a clean shutdown
Brought to you by:
orenmnero
From: Clark S. <cla...@ya...> - 2004-06-07 19:22:21
|
In my version of tradeclient, I wrote calls to system, to catch sigint (ctrl-c) and term (shutdown). I have shutdown tradeclient countless times today (more that 10 times), logoff gets called everytime, and the sequence numbers remain synched between my fix client, and the CERT Fix server at arca. This is a ***BIG*** improvement. In the past, a ctrl-c shutdown frequently caused a big disagreement between the fix client (tradeserver), and whatever server I was using. static long do_loop = 1; static void end_do_loop( int sig) { std::cerr << "signal = " << sig << " caught in tradeclient.application.cpp::end_do_loop" << endl; do_loop = 0; FIX::process_sleep( 1); } void Application::run() { struct sigaction act; act.sa_handler = end_do_loop; sigemptyset( &act.sa_mask); act.sa_flags = 0; sigaction( SIGINT, &act, 0); sigaction( SIGTERM, &act, 0); sigaction( SIGALRM, &act, 0); while ( do_loop ) { try { char action = queryAction(); if ( action == '1' ) queryEnterOrder(); else if ( action == '2' ) queryCancelOrder(); else if ( action == '3' ) queryReplaceOrder(); else if ( action == '4' ) queryMarketDataRequest(); else if ( action == '5' ) break; } catch ( std::exception & e ) { std::cout << "Message Not Sent: " << e.what(); } } } --------------------------------- Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger |