But "Resource temporarily unavailable" has absolutely no meaning to
anyone who will try to do this by hand, it is better for the message
to interpret the situation so that someone can understand.

I think your proposal makes it worse.

Klemens Nanni <k...@openbsd.org> wrote:

> To debug things, I started slaacd manually from single-user:
> 
>       boot> b /bsd -s
>       # slaacd -dv
>       slaacd: already running
> 
> We added the lock and this message to prevent multiple instances in the
> installer, where this is indeed the only error case that can happen.
> 
> But hitting it outside the installer (which entirely discards stderr)
> makes me think that the error message it too much of an assumption and
> ignores the valuable errno for no reason.
> 
> /dev/slaacd.lock couldn't be aquired because / is still read-only, so
> the following would've told me that immediately:
> 
>       # slaacd -dv
>       slaacd: lock: Read-only file system
> 
> If you actually have it running already in multi-user and start a copy:
> 
>       # obj/slaacd -dv
>       slaacd: lock: Resource temporarily unavailable
> 
> 
> The lock was introduced to fix duplicate startups in the installer;
> there the error message is entirely discarded anyway, as the only error
> should be indeed an already running instance.
> 
> Should "lock" be _PATH_LOCKFILE, i.e.
>       slaacd: /dev/slaacd.lock: Read-only file system
> 
> Feedback? Objection? OK?
> 
> Index: slaacd/slaacd.c
> ===================================================================
> RCS file: /cvs/src/sbin/slaacd/slaacd.c,v
> retrieving revision 1.66
> diff -u -p -r1.66 slaacd.c
> --- slaacd/slaacd.c   15 Sep 2022 07:59:59 -0000      1.66
> +++ slaacd/slaacd.c   26 Nov 2022 17:02:51 -0000
> @@ -180,7 +180,7 @@ main(int argc, char *argv[])
>  
>       lockfd = open(_PATH_LOCKFILE, O_CREAT|O_RDWR|O_EXLOCK|O_NONBLOCK, 0600);
>       if (lockfd == -1)
> -             errx(1, "already running");
> +             err(1, "lock");
>  
>       /* Check for assigned daemon user */
>       if (getpwnam(SLAACD_USER) == NULL)
> Index: dhcpleased/dhcpleased.c
> ===================================================================
> RCS file: /cvs/src/sbin/dhcpleased/dhcpleased.c,v
> retrieving revision 1.26
> diff -u -p -r1.26 dhcpleased.c
> --- dhcpleased/dhcpleased.c   23 Jul 2022 09:33:18 -0000      1.26
> +++ dhcpleased/dhcpleased.c   26 Nov 2022 17:02:51 -0000
> @@ -222,7 +222,7 @@ main(int argc, char *argv[])
>  
>       lockfd = open(_PATH_LOCKFILE, O_CREAT|O_RDWR|O_EXLOCK|O_NONBLOCK, 0600);
>       if (lockfd == -1)
> -             errx(1, "already running");
> +             err(1, "lock");
>  
>       /* Check for assigned daemon user */
>       if (getpwnam(DHCPLEASED_USER) == NULL)
> Index: resolvd/resolvd.c
> ===================================================================
> RCS file: /cvs/src/sbin/resolvd/resolvd.c,v
> retrieving revision 1.29
> diff -u -p -r1.29 resolvd.c
> --- resolvd/resolvd.c 14 Nov 2022 13:57:46 -0000      1.29
> +++ resolvd/resolvd.c 26 Nov 2022 17:02:50 -0000
> @@ -194,7 +194,7 @@ main(int argc, char *argv[])
>  
>       lockfd = open(_PATH_LOCKFILE, O_CREAT|O_RDWR|O_EXLOCK|O_NONBLOCK, 0600);
>       if (lockfd == -1)
> -             errx(1, "already running");
> +             err(1, "lock");
>  
>       if (!debug)
>               daemon(0, 0);
> 

Reply via email to