Skip to content

Commit

Permalink
[usb-moded] Add --auto-exit option to ease startup debugging
Browse files Browse the repository at this point in the history
Having a deterministic way to make the process exit makes it easier to debug
what happens during process startup.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Feb 20, 2019
1 parent fb3e0a2 commit 0facd5b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/usb_moded.c
Expand Up @@ -138,6 +138,7 @@ static bool usbmoded_hw_fallback = false;
#ifdef SYSTEMD
static bool usbmoded_systemd_notify = false;
#endif
static bool usbmoded_auto_exit = false;

/* ========================================================================= *
* Functions
Expand Down Expand Up @@ -731,10 +732,11 @@ static const struct option const usbmoded_long_options[] =
{ "version", no_argument, 0, 'v' },
{ "max-cable-delay", required_argument, 0, 'm' },
{ "android-bootup-function", required_argument, 0, 'b' },
{ "auto-exit", no_argument, 0, 'Q' },
{ 0, 0, 0, 0 }
};

static const char usbmoded_short_options[] = "aifsTlDdhrnvm:b:";
static const char usbmoded_short_options[] = "aifsTlDdhrnvm:b:Q";

/* Display usbmoded_usage information */
static void usbmoded_usage(void)
Expand Down Expand Up @@ -809,6 +811,10 @@ static void usbmoded_parse_options(int argc, char* argv[])
log_warning("Deprecated option: --android-bootup-function");
break;

case 'Q':
usbmoded_auto_exit = true;
break;

default:
usbmoded_usage();
exit(EXIT_FAILURE);
Expand Down Expand Up @@ -875,6 +881,10 @@ int main(int argc, char* argv[])

/* init succesful, run main loop */
usbmoded_exitcode = EXIT_SUCCESS;

if( usbmoded_auto_exit )
goto EXIT;

usbmoded_mainloop = g_main_loop_new(NULL, FALSE);

log_debug("enter usb-moded mainloop");
Expand Down

0 comments on commit 0facd5b

Please sign in to comment.