diff --git a/NEWS b/NEWS index b2ba013a..8c3f6b6f 100644 --- a/NEWS +++ b/NEWS @@ -34,6 +34,9 @@ Version 1.1.1 - Unify and improve log message output - Improve README.md with project description, installation, contributing and usage sections + - The "--foreground" flag has been removed; usbmuxd now runs in foreground by + default. For the previous behaviour, use "--background" to run in + background instead. Version 1.1.0 ~~~~~~~~~~~~~ diff --git a/README.md b/README.md index 82493582..a020229d 100644 --- a/README.md +++ b/README.md @@ -103,8 +103,8 @@ The daemon also manages pairing records with iOS devices and the host in Ensure proper permissions are setup for the daemon to access the directory. -For debugging purposes it is helpful to start usbmuxd using the foreground `-f` -argument and enable verbose mode `-v` to get suitable logs. +For debugging purposes it is helpful to enable verbose mode `-v` to get +suitable logs. Please consult the usage information or manual page for a full documentation of available command line options: diff --git a/docs/usbmuxd.8 b/docs/usbmuxd.8 index 590afdc2..5ab511bc 100644 --- a/docs/usbmuxd.8 +++ b/docs/usbmuxd.8 @@ -32,8 +32,8 @@ Ensure proper permissions are setup for the daemon to access the directory. .B \-U, \-\-user USER Change to this user after startup (needs USB privileges). .TP -.B \-f, \-\-foreground -Do not daemonize (implies one -v). +.B \-f, \-\-background +Daemonize (double fork and run in background). .TP .B \-n, \-\-disable-hotplug Disables automatic discovery of devices on hotplug. Starting another instance @@ -44,7 +44,7 @@ Enable "--exit" request from other instances and exit automatically if no device is attached. .TP .B \-u, \-\-udev -Run in udev operation mode (implies -n and -z). +Run in udev operation mode (implies -n, -b and -z). .TP .B \-s, \-\-systemd Run in systemd operation mode (implies -z and -f). diff --git a/src/main.c b/src/main.c index 8702a4b3..fce21366 100644 --- a/src/main.c +++ b/src/main.c @@ -65,7 +65,7 @@ int no_preflight = 0; // Global state for main.c static int verbose = 0; -static int foreground = 0; +static int background = 0; static int drop_privileges = 0; static const char *drop_user = NULL; static int opt_disable_hotplug = 0; @@ -504,7 +504,7 @@ static void usage() printf("OPTIONS:\n"); printf(" -h, --help\t\tPrint this message.\n"); printf(" -v, --verbose\t\tBe verbose (use twice or more to increase).\n"); - printf(" -f, --foreground\tDo not daemonize (implies one -v).\n"); + printf(" -b, --background\tDaemonize (double fork immediately).\n"); printf(" -U, --user USER\tChange to this user after startup (needs USB privileges).\n"); printf(" -n, --disable-hotplug\tDisables automatic discovery of devices on hotplug.\n"); printf(" \tStarting another instance will trigger discovery instead.\n"); @@ -512,7 +512,7 @@ static void usage() printf(" \tautomatically if no device is attached.\n"); printf(" -p, --no-preflight\tDisable lockdownd preflight on new device.\n"); #ifdef HAVE_UDEV - printf(" -u, --udev\t\tRun in udev operation mode (implies -n and -z).\n"); + printf(" -u, --udev\t\tRun in udev operation mode (implies -n, -b and -z).\n"); #endif #ifdef HAVE_SYSTEMD printf(" -s, --systemd\t\tRun in systemd operation mode (implies -z and -f).\n"); @@ -537,7 +537,7 @@ static void parse_opts(int argc, char **argv) { static struct option longopts[] = { {"help", no_argument, NULL, 'h'}, - {"foreground", no_argument, NULL, 'f'}, + {"background", no_argument, NULL, 'b'}, {"verbose", no_argument, NULL, 'v'}, {"user", required_argument, NULL, 'U'}, {"disable-hotplug", no_argument, NULL, 'n'}, @@ -577,8 +577,8 @@ static void parse_opts(int argc, char **argv) case 'h': usage(); exit(0); - case 'f': - foreground = 1; + case 'b': + background = 1; break; case 'v': ++verbose; @@ -597,12 +597,13 @@ static void parse_opts(int argc, char **argv) case 'u': opt_disable_hotplug = 1; opt_enable_exit = 1; + background = 1; break; #endif #ifdef HAVE_SYSTEMD case 's': opt_enable_exit = 1; - foreground = 1; + background = 0; break; #endif case 'n': @@ -675,7 +676,7 @@ int main(int argc, char *argv[]) argc -= optind; argv += optind; - if (!foreground && !use_logfile) { + if (background && !use_logfile) { verbose += LL_WARNING; log_enable_syslog(); } else { @@ -751,7 +752,7 @@ int main(int argc, char *argv[]) goto terminate; } - if (!foreground) { + if (background) { if ((res = daemonize()) < 0) { fprintf(stderr, "usbmuxd: FATAL: Could not daemonize!\n"); usbmuxd_log(LL_FATAL, "Could not daemonize!");