usbmuxd icon indicating copy to clipboard operation
usbmuxd copied to clipboard

Drop --foreground

Open WhyNotHugo opened this issue 2 years ago • 5 comments

Always run in foreground by default. Service manager and supervisors expect services to run in foreground, so they can track the lifetime of the child process. Those that don't implement their own logic to fork daemons anyway.

For users running usbmuxd manually, running in background by default provides a confusing experience, since it gives the impression of exiting immediately.

Anyone needing to run usbmuxd in background can use a shell's & operator or something like nohop.

WhyNotHugo avatar Nov 19 '23 12:11 WhyNotHugo

your change doesn't make sense. since i'ts daemon it need to run in background.

while it would make sense that default mode is foreground, instead of background, your code should provide option to start it optionally as background service, because that is intended purpose. therefore your proposed change should also implement optional parameter to run it as background, eg. "switch logic" and instead --foreground implement --background parameter

mexmer avatar Nov 21 '23 09:11 mexmer

That might be a good idea and be a bit more flexible. I can try and switch to a --background.

Do you have any example scenario where this would be used though? I don’t know of any service manager or supervisor which requires that daemons double-fork themselves.

WhyNotHugo avatar Nov 21 '23 10:11 WhyNotHugo

you don't always use service manager, but start directly service, for example samba, inetd, syslogd and others are started directly, same for usbmuxd, it can be started by systemd, udev, or you run it as service directly, depends on which system you use.

mexmer avatar Nov 21 '23 23:11 mexmer

you don't always use service manager, but start directly service, for example samba, inetd, syslogd and others are started directly, same for usbmuxd, it can be started by systemd, udev, or you run it as service directly, depends on which system you use.

What do you mean by "started directly"? You run them interactively via a terminal? I didn't really account for that sort of use case, I expected that most people would use something like systemd, openrc, init scripts, etc.

I've opened https://github.com/libimobiledevice/usbmuxd/pull/235 which flips the switch to --background as you suggested above.

WhyNotHugo avatar Nov 25 '23 15:11 WhyNotHugo

you don't always use service manager, but start directly service, for example samba, inetd, syslogd and others are started directly, same for usbmuxd, it can be started by systemd, udev, or you run it as service directly, depends on which system you use.

What do you mean by "started directly"? You run them interactively via a terminal? I didn't really account for that sort of use case, I expected that most people would use something like systemd, openrc, init scripts, etc.

I've opened #235 which flips the switch to --background as you suggested above.

not from commandline, but from script in init system. there are distribution that uses sysvinit or some alternative to it, instead of superservice like systemd. those expect started binary to deamonize itself. that it the way, it worked before superservice and service controllers were added to major linux distributions, and now people either forget or even don't know about it. i'm not going to argue which is better, but if you create service (daemon), you should support both ways. which is what usbmuxd doing.

mexmer avatar Nov 28 '23 08:11 mexmer