X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fserver%2Fserver.c;h=7e90d89fd2d6af7d1a3cc89b80a70186e84a6c6e;hp=73d8b5b652c97636055d72243574fc61e70d72ef;hb=19f219f731f29503c8e4d432935d3ea558cc1659;hpb=33bb0fe6194b697bfc7e89338c0ffac1c54d09be;ds=sidebyside diff --git a/src/server/server.c b/src/server/server.c index 73d8b5b652..7e90d89fd2 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -44,7 +44,8 @@ static struct service *services; -/* shutdown_openocd == 1: exit the main event loop, and quit the debugger */ +/* shutdown_openocd == 1: exit the main event loop, and quit the + * debugger; 2: quit with non-zero return code */ static int shutdown_openocd; /* store received signal to exit application by killing ourselves */ @@ -499,7 +500,7 @@ int server_loop(struct command_context *command_context) #endif } - return ERROR_OK; + return shutdown_openocd != 2 ? ERROR_OK : ERROR_FAIL; } #ifdef _WIN32 @@ -608,6 +609,13 @@ COMMAND_HANDLER(handle_shutdown_command) shutdown_openocd = 1; + if (CMD_ARGC == 1) { + if (!strcmp(CMD_ARGV[0], "error")) { + shutdown_openocd = 2; + return ERROR_FAIL; + } + } + return ERROR_COMMAND_CLOSE_CONNECTION; }