Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 72145 - start-stop-daemon does not complain when pidfile is missing
Summary: start-stop-daemon does not complain when pidfile is missing
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All All
: High normal
Assignee: Roy Marples (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 151164
  Show dependency tree
 
Reported: 2004-11-22 15:13 UTC by Eldad Zack (RETIRED)
Modified: 2006-10-16 09:57 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eldad Zack (RETIRED) gentoo-dev 2004-11-22 15:13:55 UTC
It seems that the author of start-stop-daemon deliberately let it slip when the pidfile is missing:

from start-stop-daemon.c, line 722:

static void
do_pidfile(const char *name)
{
        FILE *f;
        pid_t pid;

        f = fopen(name, "r");
        if (f) {
                if (fscanf(f, "%d", &pid) == 1)
                        check(pid);
                fclose(f);
        } else if (errno != ENOENT)
                fatal("open pidfile %s: %s", name, strerror(errno));

}

that means that if opening the pidfile fails with ENOENT it will not check any pid and will not bail with an errorcode/error message.

a fix would trivially be:

--- start-stop-daemon.c.orig    2004-05-10 17:21:55.000000000 +0300
+++ start-stop-daemon.c 2004-11-23 00:58:04.688000048 +0200
@@ -730,8 +730,7 @@
                if (fscanf(f, "%d", &pid) == 1)
                        check(pid);
                fclose(f);
-       } else if (errno != ENOENT)
-               fatal("open pidfile %s: %s", name, strerror(errno));
+       } else fatal("open pidfile %s: %s", name, strerror(errno));

 }
Comment 1 Martin Schlemmer (RETIRED) gentoo-dev 2005-07-16 09:21:54 UTC
I punted this part of the darwin patch, as its not related, and I think this
should be reviewed.

Personally I think it might go the other way, as the manpage do not say that the
pidfile have to exist .. you can for example stack --pidfile and --exec, and the
better fix might be:

-----
Index: src/start-stop-daemon.c
===================================================================
--- src/start-stop-daemon.c     (revision 1312)
+++ src/start-stop-daemon.c     (working copy)
@@ -1022,9 +1022,11 @@
 {
        clear(&found);

-       if (pidfile)
+       if (pidfile) {
                do_pidfile(pidfile);
-       else
+               if (!found)
+                       do_procinit();
+       } else
                do_procinit();
 }

Comment 2 Eldad Zack (RETIRED) gentoo-dev 2006-10-07 09:09:17 UTC
any resolution to this issue? should this we close this as WONTFIX?
Comment 3 Roy Marples (RETIRED) gentoo-dev 2006-10-08 12:03:04 UTC
(In reply to comment #2)
> any resolution to this issue? should this we close this as WONTFIX?

No, it's just not something we've gotten around to yet.
Comment 4 Roy Marples (RETIRED) gentoo-dev 2006-10-16 06:41:24 UTC
OK, this is a problem and will be fixed in baselayout-1.13.0_alpha2
Comment 5 Roy Marples (RETIRED) gentoo-dev 2006-10-16 09:57:36 UTC
Your both right btw - we need to only error if we're stopping :)

Anyway, alpha2 is out so fixed.