diff --git a/rmw_zenoh_cpp/src/zenohd/main.cpp b/rmw_zenoh_cpp/src/zenohd/main.cpp index 0227b9d4..233850bb 100644 --- a/rmw_zenoh_cpp/src/zenohd/main.cpp +++ b/rmw_zenoh_cpp/src/zenohd/main.cpp @@ -199,6 +199,11 @@ int main(int argc, char ** argv) printf("Unable to open router session!\n"); return 1; } + auto close_session = rcpputils::make_scope_exit( + [&session]() { + z_close(z_move(session)); + }); + printf( "Started Zenoh router with id %s.\n", rmw_zenoh_cpp::liveliness::zid_to_str(z_info_zid(z_session_loan(&session))).c_str()); @@ -209,11 +214,6 @@ int main(int argc, char ** argv) signal(SIGTERM, quit); #endif - auto close_session = rcpputils::make_scope_exit( - [&session]() { - z_close(z_move(session)); - }); - KeyboardReader keyreader; char c = 0;