client: Fix exit codes for /help and similar option
Currently, non-zero exit code is returned for /version, /buildconfig, /help,
/monitor-list, /kbd-list and /kbd-lang-list command-line options for several
clients. This is against conventions because 0 is usually returned in
such cases. Also, there is potentially another problem that the returned
codes overflow on UNIX systems (where the exit code is a number between 0
and 255). Let's fix the clients to return 0 in the mentioned cases to honor
conventions and 1 for the command-line parsing errors (or -1 for clients
who already use that value).
Fixes: https://github.com/FreeRDP/FreeRDP/issues/6686
(cherry picked from commit 3ee4cabcfa
)
This commit is contained in:
parent
4d409b7c4b
commit
cf3ba75673
@ -338,12 +338,13 @@ int main(int argc, char* argv[])
|
|||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
status = freerdp_client_settings_parse_command_line(context->settings, argc, argv, FALSE);
|
status = freerdp_client_settings_parse_command_line(context->settings, argc, argv, FALSE);
|
||||||
status =
|
|
||||||
freerdp_client_settings_command_line_status_print(context->settings, status, argc, argv);
|
|
||||||
|
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
rc = 0;
|
freerdp_client_settings_command_line_status_print(context->settings, status, argc, argv);
|
||||||
|
|
||||||
|
if (status <= COMMAND_LINE_STATUS_PRINT && status >= COMMAND_LINE_STATUS_PRINT_LAST)
|
||||||
|
rc = 0;
|
||||||
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,18 +628,19 @@ int main(int argc, char* argv[])
|
|||||||
settings = context->settings;
|
settings = context->settings;
|
||||||
|
|
||||||
status = freerdp_client_settings_parse_command_line(settings, argc, argv, FALSE);
|
status = freerdp_client_settings_parse_command_line(settings, argc, argv, FALSE);
|
||||||
status = freerdp_client_settings_command_line_status_print(settings, status, argc, argv);
|
|
||||||
|
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
BOOL list = settings->ListMonitors;
|
BOOL list = settings->ListMonitors;
|
||||||
|
|
||||||
|
freerdp_client_settings_command_line_status_print(settings, status, argc, argv);
|
||||||
|
|
||||||
if (list)
|
if (list)
|
||||||
wlf_list_monitors(wlc);
|
wlf_list_monitors(wlc);
|
||||||
|
|
||||||
freerdp_client_context_free(context);
|
if (status <= COMMAND_LINE_STATUS_PRINT && status >= COMMAND_LINE_STATUS_PRINT_LAST)
|
||||||
if (list)
|
rc = 0;
|
||||||
return 0;
|
|
||||||
return status;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (freerdp_client_start(context) != 0)
|
if (freerdp_client_start(context) != 0)
|
||||||
|
@ -108,6 +108,10 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
freerdp_client_settings_command_line_status_print(settings, status, argc, argv);
|
freerdp_client_settings_command_line_status_print(settings, status, argc, argv);
|
||||||
|
|
||||||
|
if (status <= COMMAND_LINE_STATUS_PRINT && status >= COMMAND_LINE_STATUS_PRINT_LAST)
|
||||||
|
rc = 0;
|
||||||
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
int rc = 1;
|
||||||
int status;
|
int status;
|
||||||
HANDLE thread;
|
HANDLE thread;
|
||||||
xfContext* xfc;
|
xfContext* xfc;
|
||||||
@ -56,31 +57,34 @@ int main(int argc, char* argv[])
|
|||||||
xfc = (xfContext*)context;
|
xfc = (xfContext*)context;
|
||||||
|
|
||||||
status = freerdp_client_settings_parse_command_line(context->settings, argc, argv, FALSE);
|
status = freerdp_client_settings_parse_command_line(context->settings, argc, argv, FALSE);
|
||||||
|
|
||||||
status = freerdp_client_settings_command_line_status_print(settings, status, argc, argv);
|
|
||||||
|
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
BOOL list = settings->ListMonitors;
|
BOOL list = settings->ListMonitors;
|
||||||
|
|
||||||
|
freerdp_client_settings_command_line_status_print(settings, status, argc, argv);
|
||||||
|
|
||||||
if (list)
|
if (list)
|
||||||
xf_list_monitors(xfc);
|
xf_list_monitors(xfc);
|
||||||
|
|
||||||
freerdp_client_context_free(context);
|
if (status <= COMMAND_LINE_STATUS_PRINT && status >= COMMAND_LINE_STATUS_PRINT_LAST)
|
||||||
if (list)
|
rc = 0;
|
||||||
return 0;
|
|
||||||
return status;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
freerdp_client_start(context);
|
if (freerdp_client_start(context) != 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
thread = freerdp_client_get_thread(context);
|
thread = freerdp_client_get_thread(context);
|
||||||
|
|
||||||
WaitForSingleObject(thread, INFINITE);
|
WaitForSingleObject(thread, INFINITE);
|
||||||
GetExitCodeThread(thread, &dwExitCode);
|
GetExitCodeThread(thread, &dwExitCode);
|
||||||
|
rc = xf_exit_code_from_disconnect_reason(dwExitCode);
|
||||||
|
|
||||||
freerdp_client_stop(context);
|
freerdp_client_stop(context);
|
||||||
|
|
||||||
|
out:
|
||||||
freerdp_client_context_free(context);
|
freerdp_client_context_free(context);
|
||||||
|
|
||||||
return xf_exit_code_from_disconnect_reason(dwExitCode);
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,7 @@
|
|||||||
#define COMMAND_LINE_STATUS_PRINT_HELP -2002
|
#define COMMAND_LINE_STATUS_PRINT_HELP -2002
|
||||||
#define COMMAND_LINE_STATUS_PRINT_VERSION -2003
|
#define COMMAND_LINE_STATUS_PRINT_VERSION -2003
|
||||||
#define COMMAND_LINE_STATUS_PRINT_BUILDCONFIG -2004
|
#define COMMAND_LINE_STATUS_PRINT_BUILDCONFIG -2004
|
||||||
|
#define COMMAND_LINE_STATUS_PRINT_LAST -2999
|
||||||
|
|
||||||
/* Command-Line Macros */
|
/* Command-Line Macros */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user