@@ -883,6 +883,9 @@ static int handle_command(const std::vector<std::string> &args, std::string &out
883883 if (args.size () == 1 && args[0 ] == " start" ) {
884884 rtapi_print_msg (RTAPI_MSG_ERR , " rtapi_app: start received while running\n " );
885885 return 0 ;
886+ } else if (args.size () == 1 && args[0 ] == " ping" ) {
887+ // Just return success
888+ return 0 ;
886889 } else if (args.size () == 1 && args[0 ] == " exit" ) {
887890 force_exit = 1 ;
888891 return 0 ;
@@ -1169,7 +1172,19 @@ int main(int argc, char **argv) {
11691172 // Start a master on start command
11701173 if (args.size () == 1 && args[0 ] == " start" ) {
11711174 result = start_master (fd);
1172- exit (result);
1175+ if (result != 0 ) {
1176+ exit (result);
1177+ }
1178+ // Need to close and reopen the socket
1179+ // It is already bound and master is using it
1180+ close (fd);
1181+ int fd = create_socket ();
1182+ if (fd < 0 ) {
1183+ exit (1 );
1184+ }
1185+ // Ping master to make shure it is running
1186+ // before returning
1187+ return run_slave_cmd (&addr, fd, {" ping" });
11731188 }else {
11741189 fprintf (stderr, " WARNING: Deprecated: No master found. Use \" realtime start\" to start one.\n "
11751190 " A master is started automatically.\n "
@@ -1187,6 +1202,8 @@ int main(int argc, char **argv) {
11871202 if (fd < 0 ) {
11881203 exit (1 );
11891204 }
1205+ // Run command
1206+ // This makes also shure it is running before returning
11901207 return run_slave_cmd (&addr, fd, args);
11911208 }
11921209 } else if (errno == EADDRINUSE ) {
0 commit comments