Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace --foreground with --background #235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions docs/usbmuxd.8
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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).
Expand Down
19 changes: 10 additions & 9 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -504,15 +504,15 @@ 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");
printf(" -z, --enable-exit\tEnable \"--exit\" request from other instances and exit\n");
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");
Expand All @@ -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'},
Expand Down Expand Up @@ -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;
Expand All @@ -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':
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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!");
Expand Down