gLSB: sysinit: clearify algorithm for determining status of programs
Tobias Burnus <[email protected]>
| Newsgroups | gmane.linux.lsb.discuss |
|---|---|
| Message-ID | <[email protected]> |
Hi, this patch does: - use some more caps for the titles for consistancy - move is-program-running section from pidofproc into a dedicated paragraph - programs should delete pidfile if they are stopped - discourage to use _only_ /proc/PID/exe to check whether a program is running since this prevents e.g. perl-based daemons See bug #677744 and http://freestandards.org/pipermail/lsb-discuss/2003-July/001716.html This affects Debian. (RedHat and SuSE are known to be not-affected.) - killproc should delete the pidfile, if the program has been stopped and the file still exists. Reasoning: a SIGKILLed program can not remove it itself. - pidofproc shall only return pids of running processes. The changes should reflect the de-facto used methods, except for: - check whether a program is running for script-based daemons -> this fails at least in Debian (Debian bug 167757) - deleting of the pid file by killproc if the program is no longer running - returning only pids of running processes (SuSE and RedHat check for this, Debian, see bug 207639) Note that those are only "should" clauses. (Distributors:) Please check whether there is any clash with a current implementation which behaviour should be still allowed or used instead. Tobias
sysinit.diff
(text/plain, 6.6 KB)
? sysinit.diff Index: facnames.sgml =================================================================== RCS file: /cvsroot/lsb/lsbspec/gLSB/sysinit/facnames.sgml,v retrieving revision 1.9 diff -u -r1.9 facnames.sgml --- facnames.sgml 12 Aug 2003 21:31:28 -0000 1.9 +++ facnames.sgml 28 Aug 2003 19:34:37 -0000 @@ -1,6 +1,6 @@ <SECT1 ID=facilname> -<TITLE>Facility names</TITLE> +<TITLE>Facility Names</TITLE> <PARA> Boot facilities are used to indicate dependencies in init scripts, as Index: initfunctions.sgml =================================================================== RCS file: /cvsroot/lsb/lsbspec/gLSB/sysinit/initfunctions.sgml,v retrieving revision 1.11 diff -u -r1.11 initfunctions.sgml --- initfunctions.sgml 12 Aug 2003 21:31:28 -0000 1.11 +++ initfunctions.sgml 28 Aug 2003 19:34:37 -0000 @@ -1,6 +1,6 @@ <SECT1 ID=iniscrptfunc> -<TITLE>Init script Functions</TITLE> +<TITLE>Init Script Functions</TITLE> <PARA> Each LSB-compliant init.d script shall source the file @@ -13,14 +13,35 @@ defined by POSIX.2. </PARA> +<PARA> +The <code>start_daemon</code>, <code>killproc</code> and <code>pidofproc</code> +functions shall use this algorithm for determining the status and the pid(s) +of the specified program. They shall read the pidfile specified or otherwise +<code>/var/run/basename.pid</code>. +The method used to determine whether a program is running is implementation +defined, but should allow for non-binary programs. +<footnote> +This note is only informative. Common methods check either for the existance +of the <code>/proc/pid</code> directory or use <code>/proc/pid/exe</code> +and <code>/proc/pid/cmdline</code>. Relying only on +<code>/proc/pid/exe</code> is discouraged since this results in a +not-running status for daemons that are written in a script language. +</footnote> +Complient implementations may attempt to use other mechanisms for determining +the pid(s). Compliant applications should not rely on such mechanisms and use +a pidfile, which should be deleted when the program is stopped. Multiple pid(s) +shall be separated by a single space in the pidfile and in the output of +<code>pidofproc</code>. +</PARA> + <SIMPLELIST type=horiz columns=2> <MEMBER>start_daemon [-f] [-n nicelevel] [-p pidfile] pathname [args]</MEMBER> <MEMBER> This runs the specified program as a daemon. -start_daemon will check to see if the program is already running -using the algorithm given by pidofproc. If so, it will not -start another copy of the daemon unless the -f +start_daemon shall check if the program is already running +using the algorithm given above. If so, it shall not +start another copy of the daemon unless the <code>-f</code> option is given. The -n option specifies a nice level. See nice(1). start_daemon should return the LSB defined exit status codes. It @@ -32,14 +53,16 @@ <MEMBER> This stops the specified program. The program is -found using the algorithm given by pidofproc. If a +found using the algorithm given above. If a signal is specified, using the -<replaceable>signal_name</replaceable> or -<replaceable>signal_number</replaceable> syntaxes -specified by the <command>kill</command> command, +as specified by the <command>kill</command> command, the program is sent that signal. Otherwise, a SIGTERM followed by a SIGKILL -after some number of seconds is sent. +after some number of seconds shall be sent. +If a program has been terminated, the pidfile should be removed if the +terminated process has not already done so. Compliant applications may use the basename instead of the pathname. killproc should return the LSB defined exit status codes. If called @@ -52,22 +75,10 @@ <MEMBER> This function returns one or more pid(s) for a particular -daemon. If an entry is found in -/var/run/basename.pid, then that value is returned. -If the -p option is used, the given pidfile is used instead. -Compliant applications may use the basename instead of the -pathname. -Compliant implementations of the LSB may attempt -other mechanisms for determining the pid(s), -although this is not required (and not -recommended, since a user can trick startup scripts -by creating processes that appear to be system -programs in the process list thus creating a -potential security exposure). Hence, LSB-complaint -applications who wish to use the pidofproc function -in their init scripts shall store the pid in -/var/run/basename.pid. multiple pids should be separated by a single space. -pidofproc should return the LSB defined exist status +daemon using the algorithm given above. Only pids of running processes +should be returned. +Compliant applications may use the basename instead of the pathname. +pidofproc should return the LSB defined exit status codes for "status". It shall return 0 if the program is running and not 0 otherwise. </MEMBER> Index: initscripts.sgml =================================================================== RCS file: /cvsroot/lsb/lsbspec/gLSB/sysinit/initscripts.sgml,v retrieving revision 1.12 diff -u -r1.12 initscripts.sgml --- initscripts.sgml 12 Aug 2003 21:31:28 -0000 1.12 +++ initscripts.sgml 28 Aug 2003 19:34:37 -0000 @@ -1,6 +1,6 @@ <SECT1 ID=initscrcomconv> -<TITLE>Comment conventions for init scripts</TITLE> -<TITLEABBREV ID="initscriptsShort">Comment conventions for init scripts</TITLEABBREV> +<TITLE>Comment Conventions for Init Scripts</TITLE> +<TITLEABBREV ID="initscriptsShort">Comment Conventions for Init Scripts</TITLEABBREV> <PARA> LSB applications which need to execute script(s) at bootup and/or Index: installinit.sgml =================================================================== RCS file: /cvsroot/lsb/lsbspec/gLSB/sysinit/installinit.sgml,v retrieving revision 1.5 diff -u -r1.5 installinit.sgml --- installinit.sgml 23 Jul 2003 18:08:05 -0000 1.5 +++ installinit.sgml 28 Aug 2003 19:34:37 -0000 @@ -1,6 +1,6 @@ <SECT1 ID=initsrcinstrm> -<TITLE>Installation and removal of init.d files</TITLE> +<TITLE>Installation and Removal of init.d Files</TITLE> <PARA> An init.d file is installed by copying it into /etc/init.d (which may Index: scriptnames.sgml =================================================================== RCS file: /cvsroot/lsb/lsbspec/gLSB/sysinit/scriptnames.sgml,v retrieving revision 1.11 diff -u -r1.11 scriptnames.sgml --- scriptnames.sgml 12 Aug 2003 21:31:28 -0000 1.11 +++ scriptnames.sgml 28 Aug 2003 19:34:37 -0000 @@ -1,6 +1,6 @@ <SECT1 ID=scrptnames> -<TITLE>Script names</TITLE> +<TITLE>Script Names</TITLE> <PARA> Since the init.d scripts shall live in a single directory, they shall