2009-12-04 15:15:20 +01:00
|
|
|
--- .dummy
|
2009-12-07 15:53:19 +01:00
|
|
|
+++ .dummy 2009-08-19 10:18:39.181901099 +0000
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+this is a dummy, remove if real changes are required
|
2009-12-07 15:53:19 +01:00
|
|
|
--- checkproc.c
|
2009-12-08 12:16:08 +01:00
|
|
|
+++ checkproc.c 2009-12-07 15:42:55.783429631 +0000
|
2009-12-07 15:53:19 +01:00
|
|
|
@@ -92,7 +92,6 @@ int main(int argc, char **argv)
|
|
|
|
/* Allocate here: address optarg (current *argv) isn't freeable */
|
|
|
|
if (optarg && !pid_file) {
|
|
|
|
pid_file = xstrdup(optarg);
|
|
|
|
- pid_forced = true;
|
|
|
|
} else
|
|
|
|
error(WRGSYNTAX, "Option -p requires pid file to read pid from\n");
|
|
|
|
break;
|
|
|
|
@@ -148,7 +147,8 @@ int main(int argc, char **argv)
|
|
|
|
pid_file = (char*) xmalloc(DEFPIDLEN+strlen(basename)+1);
|
|
|
|
pid_file = strcat(strcat(strcpy(pid_file,DEFPIDDIR),basename),DEFPIDEXT);
|
|
|
|
}
|
|
|
|
- }
|
|
|
|
+ } else
|
|
|
|
+ pid_forced = true;
|
|
|
|
|
|
|
|
/* Check and verify the pid file */
|
|
|
|
errno = 0;
|
2009-12-08 12:16:08 +01:00
|
|
|
@@ -168,17 +168,22 @@ int main(int argc, char **argv)
|
|
|
|
if (!remember)
|
|
|
|
exit(LSB_STATUS_NOPROC); /* New LSB: no pid file is no job */
|
|
|
|
}
|
|
|
|
- /* No pid file means that we have to search in /proc/ */
|
|
|
|
free(pid_file);
|
|
|
|
pid_file = NULL;
|
|
|
|
+
|
|
|
|
+ /* No pid file means that we have to search in /proc/ */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pid_file && !st.st_size) {
|
|
|
|
warn("Empty pid file %s for %s\n", pid_file, fullname);
|
|
|
|
|
|
|
|
- /* No pid file means that we have to search in /proc/ */
|
|
|
|
free(pid_file);
|
|
|
|
pid_file = NULL;
|
|
|
|
+
|
|
|
|
+ if (pid_forced)
|
|
|
|
+ exit(LSB_STATUS_NOPROC);
|
|
|
|
+
|
|
|
|
+ /* No pid file means that we have to search in /proc/ */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check and verify the ignore file */
|
|
|
|
@@ -205,6 +210,8 @@ int main(int argc, char **argv)
|
|
|
|
exit(LSB_STATUS_PROOFX);
|
|
|
|
}
|
|
|
|
if (!remember) { /* No process found with pid file */
|
|
|
|
+ if (pid_forced)
|
|
|
|
+ exit(LSB_STATUS_NOPROC);
|
|
|
|
if (pidof(fullname,root,flags) < 0)
|
|
|
|
exit(LSB_STATUS_PROOFX);
|
|
|
|
}
|
2010-04-14 15:37:58 +02:00
|
|
|
--- killproc.8
|
2010-07-20 11:48:27 +02:00
|
|
|
+++ killproc.8 2010-07-20 09:30:00.775424897 +0000
|
2010-04-14 15:37:58 +02:00
|
|
|
@@ -57,9 +57,11 @@ is sent. If this program is not called w
|
|
|
|
.B killproc
|
|
|
|
then
|
|
|
|
.B SIGHUP
|
|
|
|
-is used. Note that if
|
2010-07-20 11:48:27 +02:00
|
|
|
+is used. Note that if no signal is specified on the command line and the program
|
2010-04-14 15:37:58 +02:00
|
|
|
+.B killproc
|
2010-07-20 11:48:27 +02:00
|
|
|
+can not terminate a process with the default
|
2010-04-14 15:37:58 +02:00
|
|
|
.B SIGTERM
|
|
|
|
-is used and does not terminate a process the signal
|
|
|
|
+the signal
|
|
|
|
.B SIGKILL
|
|
|
|
is send after a few seconds (default is 5 seconds, see option
|
|
|
|
.BR \-t ).
|
2010-07-20 11:48:27 +02:00
|
|
|
@@ -240,16 +242,21 @@ or by number
|
|
|
|
.B \-t\fI<sec>\fP
|
|
|
|
The number
|
|
|
|
.I <sec>
|
|
|
|
-specifies the seconds to wait between the sent signal
|
|
|
|
+specifies the seconds to wait between the default signal
|
|
|
|
.B SIGTERM
|
|
|
|
and the subsequentially signal
|
|
|
|
.B SIGKILL
|
|
|
|
if the first
|
|
|
|
.B SIGTERM
|
|
|
|
does not show any result within the
|
|
|
|
-first few milli seconds. This defaults to
|
|
|
|
+first few milli seconds. This timeout defaults to
|
|
|
|
.B 5
|
|
|
|
-seconds.
|
|
|
|
+seconds. On the other hand if the signal
|
|
|
|
+.B SIGTERM
|
|
|
|
+was explicitly used on the command line, the signal
|
|
|
|
+.B SIGKILL
|
|
|
|
+will be omitted, even if the process was not terminated
|
|
|
|
+after the timeout has expired.
|
|
|
|
.TP
|
|
|
|
.B \-q
|
|
|
|
This option is ignored.
|
|
|
|
@@ -278,7 +285,7 @@ then the pid from this file is being use
|
|
|
|
terminate the sendmail process. Other running processes are
|
|
|
|
ignored.
|
|
|
|
.TP
|
|
|
|
-.B killproc -p /var/myrun/lpd.pid -TERM /usr/sbin/lpd
|
|
|
|
+.B killproc -p /var/myrun/lpd.pid /usr/sbin/lpd
|
|
|
|
.IP
|
|
|
|
sends the signal
|
|
|
|
.B SIGTERM
|
|
|
|
@@ -293,7 +300,7 @@ does not exist,
|
|
|
|
assumes that the daemon of
|
|
|
|
.B /usr/sbin/lpd
|
|
|
|
is not running. The exit status
|
|
|
|
-is set to 0 for successfully delivering the given signals
|
|
|
|
+is set to 0 for successfully delivering the default signals
|
|
|
|
.BR SIGTERM " and " SIGKILL
|
|
|
|
otherwise to 7 if the program was not running. It is also
|
|
|
|
successful if
|
2009-12-07 15:53:19 +01:00
|
|
|
--- killproc.c
|
2010-07-20 11:48:27 +02:00
|
|
|
+++ killproc.c 2010-07-20 09:35:09.234925068 +0000
|
2010-04-14 15:37:58 +02:00
|
|
|
@@ -48,6 +48,7 @@ int main(int argc, char **argv)
|
|
|
|
int process_group = 0, group_leader = 0, wait = 5, iargc = 0;
|
|
|
|
unsigned short flags = (KILL|PIDOF|KSTOP);
|
|
|
|
boolean pid_forced = false;
|
|
|
|
+ boolean sig_forced = true;
|
|
|
|
|
|
|
|
we_are = base_name(argv[0]);
|
|
|
|
openlog (we_are, LOG_OPTIONS, LOG_FACILITY);
|
|
|
|
@@ -79,11 +80,13 @@ int main(int argc, char **argv)
|
|
|
|
memset(sig, 0, len);
|
|
|
|
*sig = 'q'; /* set dummy option -q */
|
|
|
|
snum = tmp;
|
|
|
|
+ sig_forced = false;
|
|
|
|
break;
|
|
|
|
} else if ( (tmp = signame_to_signum(sig)) > 0 ) {
|
|
|
|
memset(sig, 0, len);
|
|
|
|
*sig = 'q'; /* set dummy option -q */
|
|
|
|
snum = tmp;
|
|
|
|
+ sig_forced = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -135,7 +138,6 @@ int main(int argc, char **argv)
|
2009-12-07 15:53:19 +01:00
|
|
|
/* Allocate here: address optarg (current *argv) isn't freeable */
|
|
|
|
if (optarg && !pid_file) {
|
|
|
|
pid_file = xstrdup(optarg);
|
|
|
|
- pid_forced = true;
|
|
|
|
} else
|
|
|
|
error(LSB_WRGSYN,"Option -p requires pid file to read pid from\n");
|
|
|
|
break;
|
2010-04-14 15:37:58 +02:00
|
|
|
@@ -195,7 +197,8 @@ int main(int argc, char **argv)
|
2009-12-08 12:16:08 +01:00
|
|
|
pid_file = (char*) xmalloc(DEFPIDLEN+strlen(basename)+1);
|
|
|
|
pid_file = strcat(strcat(strcpy(pid_file,DEFPIDDIR),basename),DEFPIDEXT);
|
|
|
|
}
|
2009-12-07 15:53:19 +01:00
|
|
|
- }
|
|
|
|
+ } else
|
|
|
|
+ pid_forced = true;
|
|
|
|
|
2009-12-08 12:16:08 +01:00
|
|
|
/* Check and verify the pid file */
|
|
|
|
errno = 0;
|
2010-04-14 15:37:58 +02:00
|
|
|
@@ -215,17 +218,22 @@ int main(int argc, char **argv)
|
2009-12-08 12:16:08 +01:00
|
|
|
if (!remember)
|
|
|
|
exit(LSB_NOPROC); /* New LSB: no pid file is no job */
|
|
|
|
}
|
|
|
|
- /* No pid file means that we have to search in /proc/ */
|
|
|
|
free(pid_file);
|
|
|
|
pid_file = NULL;
|
|
|
|
+
|
|
|
|
+ /* No pid file means that we have to search in /proc/ */
|
|
|
|
}
|
|
|
|
|
2009-12-07 15:53:19 +01:00
|
|
|
if (pid_file && !st.st_size) {
|
|
|
|
warn("Empty pid file %s for %s\n", pid_file, fullname);
|
2009-12-08 12:16:08 +01:00
|
|
|
|
|
|
|
- /* No pid file means that we have to search in /proc/ */
|
|
|
|
free(pid_file);
|
|
|
|
pid_file = NULL;
|
|
|
|
+
|
|
|
|
+ if (pid_forced)
|
|
|
|
+ exit(LSB_STATUS_NOPROC);
|
|
|
|
+
|
|
|
|
+ /* No pid file means that we have to search in /proc/ */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pid_file) { /* The case of having a pid file */
|
2010-07-20 11:48:27 +02:00
|
|
|
@@ -291,7 +299,10 @@ again:
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (snum == SIGKILL)
|
|
|
|
+ if (snum == SIGKILL) /* SIGKILL was specified on the command line */
|
|
|
|
+ goto badterm;
|
|
|
|
+
|
|
|
|
+ if (!sig_forced) /* SIGTERM was specified on the command line */
|
|
|
|
goto badterm;
|
2010-04-14 15:37:58 +02:00
|
|
|
|
2010-07-20 11:48:27 +02:00
|
|
|
if (check_pids(fullname,root,flags) < 0)
|
2009-10-03 02:29:19 +02:00
|
|
|
--- libinit.c
|
2009-12-07 15:53:19 +01:00
|
|
|
+++ libinit.c 2009-10-28 09:47:13.711429753 +0000
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -320,13 +320,15 @@ static ssize_t xread(int fd, void *inbuf
|
|
|
|
while (1) {
|
|
|
|
errno = 0;
|
|
|
|
bytes = read(fd, inbuf, count);
|
|
|
|
- if (bytes < 0 && (errno == EINTR || errno == EAGAIN))
|
|
|
|
- continue;
|
|
|
|
- if (bytes < 0)
|
|
|
|
+ if (bytes < 0) {
|
|
|
|
+ if (errno == EINTR || errno == EAGAIN)
|
|
|
|
+ continue;
|
|
|
|
+ if (errno == ESRCH)
|
|
|
|
+ goto out;
|
|
|
|
break;
|
|
|
|
+ }
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
-
|
|
|
|
warn("xread error: %s\n", strerror(errno));
|
|
|
|
out:
|
|
|
|
errno = olderr;
|
|
|
|
@@ -446,9 +448,9 @@ static pid_t getpppid(const pid_t ppid)
|
2009-10-03 02:29:19 +02:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
if ((fp = open(proc(pid, "stat"), O_PROCMODE)) != -1) {
|
|
|
|
- xread(fp, buf, BUFSIZ);
|
|
|
|
+ ssize_t len = xread(fp, buf, BUFSIZ);
|
|
|
|
close(fp);
|
|
|
|
- if (sscanf(buf,"%*d %*s %*c %d %*d %*d", &pppid) != 1)
|
|
|
|
+ if (len <= 0 || sscanf(buf,"%*d %*s %*c %d %*d %*d", &pppid) != 1)
|
|
|
|
warn("can not read ppid for process %d!\n", ppid);
|
|
|
|
}
|
|
|
|
out:
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -591,10 +593,11 @@ int pidof (const char * inname, const ch
|
2009-10-03 02:29:19 +02:00
|
|
|
char ent[3];
|
|
|
|
boolean thread;
|
|
|
|
ssize_t len;
|
|
|
|
+
|
|
|
|
len = xread(fp,ent,3);
|
|
|
|
close(fp);
|
|
|
|
|
|
|
|
- if (!len)
|
|
|
|
+ if (len <= 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
thread = (strncmp(ent, "0 ", 2) == 0);
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -682,6 +685,9 @@ int pidof (const char * inname, const ch
|
2009-10-03 02:29:19 +02:00
|
|
|
len = xread(fp, entry, PATH_MAX);
|
|
|
|
close(fp);
|
|
|
|
|
|
|
|
+ if (len <= 0)
|
|
|
|
+ continue;
|
|
|
|
+
|
|
|
|
/* Seek for a script not for a binary */
|
|
|
|
if (!(scrpt = checkscripts(entry, root, len, d->d_name)))
|
|
|
|
continue;
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -713,7 +719,7 @@ int pidof (const char * inname, const ch
|
2009-10-03 02:29:19 +02:00
|
|
|
len = xread(fp, entry, PATH_MAX);
|
|
|
|
close(fp);
|
|
|
|
|
|
|
|
- if (!len)
|
|
|
|
+ if (len <= 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
comm = index(entry, ' ');
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -764,7 +770,8 @@ int verify_pidfile (const char * pid_fil
|
2009-10-03 02:29:19 +02:00
|
|
|
const char * root, unsigned short flags,
|
|
|
|
const boolean ignore)
|
|
|
|
{
|
|
|
|
- int fp, cnt;
|
|
|
|
+ int fp;
|
|
|
|
+ ssize_t cnt;
|
|
|
|
boolean isscrpt = false;
|
|
|
|
pid_t pid;
|
|
|
|
char *swapname = NULL, *bufp;
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -789,11 +796,12 @@ int verify_pidfile (const char * pid_fil
|
2009-10-03 02:29:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
- if ((cnt = xread (fp, buf, BUFSIZ)) < 0) {
|
|
|
|
+ cnt = xread(fp, buf, BUFSIZ);
|
|
|
|
+ close(fp);
|
|
|
|
+ if (cnt < 0) {
|
|
|
|
warn("Can not read pid file %s: %s\n", pid_file, strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
- close(fp);
|
|
|
|
buf[cnt] = '\0';
|
|
|
|
|
|
|
|
bufp = buf;
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -847,10 +855,11 @@ int verify_pidfile (const char * pid_fil
|
2009-10-03 02:29:19 +02:00
|
|
|
char ent[3];
|
|
|
|
boolean thread;
|
|
|
|
ssize_t len;
|
|
|
|
+
|
|
|
|
len = xread(fp, ent, sizeof(ent));
|
|
|
|
close(fp);
|
|
|
|
|
|
|
|
- if (!len)
|
|
|
|
+ if (len <= 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
thread = (strncmp(ent, "0 ", 2) == 0);
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -932,6 +941,9 @@ int verify_pidfile (const char * pid_fil
|
2009-10-03 02:29:19 +02:00
|
|
|
len = xread(fp, entry, PATH_MAX);
|
|
|
|
close(fp);
|
|
|
|
|
|
|
|
+ if (len <= 0)
|
|
|
|
+ goto out;
|
|
|
|
+
|
|
|
|
/* Seek for a script not for a binary */
|
|
|
|
if (!(scrpt = checkscripts(entry, root, len, buf)))
|
|
|
|
goto out; /* Nothing found */
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -951,7 +963,7 @@ int verify_pidfile (const char * pid_fil
|
2009-10-03 02:29:19 +02:00
|
|
|
len = xread(fp, entry, PATH_MAX);
|
|
|
|
close(fp);
|
|
|
|
|
|
|
|
- if (!len)
|
|
|
|
+ if (len <= 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
comm = index(entry, ' ');
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -1040,7 +1052,7 @@ int check_pids (const char * inname, con
|
2009-10-03 02:29:19 +02:00
|
|
|
len = xread(fp, ent, sizeof(ent));
|
|
|
|
close(fp);
|
|
|
|
|
|
|
|
- if (!len)
|
|
|
|
+ if (len <= 0)
|
|
|
|
goto ignore; /* Bogus */
|
|
|
|
|
|
|
|
thread = (strncmp(ent, "0 ", 2) == 0);
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -1111,7 +1123,7 @@ int check_pids (const char * inname, con
|
2009-10-03 02:29:19 +02:00
|
|
|
len = xread(fp, entry, PATH_MAX);
|
|
|
|
close(fp);
|
|
|
|
|
|
|
|
- if (!len)
|
|
|
|
+ if (len <= 0)
|
|
|
|
goto ignore; /* Bogus */
|
|
|
|
|
|
|
|
/* Seek for a script not for a binary */
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -1131,7 +1143,7 @@ int check_pids (const char * inname, con
|
2009-10-03 02:29:19 +02:00
|
|
|
len = xread(fp, entry, PATH_MAX);
|
|
|
|
close(fp);
|
|
|
|
|
|
|
|
- if (!len)
|
|
|
|
+ if (len <= 0)
|
|
|
|
goto ignore; /* Bogus */
|
|
|
|
|
|
|
|
comm = index(entry, ' ');
|
2009-12-07 15:53:19 +01:00
|
|
|
--- startproc.8
|
|
|
|
+++ startproc.8 2009-12-03 17:00:05.739929445 +0000
|
|
|
|
@@ -59,9 +59,15 @@ processes are found. Note that
|
|
|
|
is designed to start a daemon but not a kernel thread or
|
|
|
|
a program which enables a kernel thread.
|
|
|
|
.PP
|
|
|
|
+Without any option
|
|
|
|
.B startproc
|
|
|
|
-does not use the pid to search for a process but the full
|
|
|
|
-path of the corresponding program which is used to identify the executable
|
|
|
|
+does search for a process by using the full
|
|
|
|
+path of the corresponding program and a default pid file
|
|
|
|
+.RB (/var/run/ <basename> .pid)
|
|
|
|
+which are used together to identify the executable
|
|
|
|
+out from the
|
|
|
|
+.I /proc
|
|
|
|
+file system
|
|
|
|
.RB (see " proc" (5)).
|
|
|
|
Only if the inode number
|
|
|
|
.RB (/proc/ <pid> /exe)
|
|
|
|
@@ -81,7 +87,7 @@ changed due to the LSB specification).
|
|
|
|
If this option is specified,
|
|
|
|
.B startproc
|
|
|
|
tries to check against the pid read from this file
|
|
|
|
-instead of the default
|
|
|
|
+instead of the default pid file
|
|
|
|
.RB (/var/run/ <basename> .pid).
|
|
|
|
The pid read from this file is compared against the pids of possible
|
|
|
|
running processes that use the specified executable. In order to avoid
|
|
|
|
--- startproc.c
|
2009-12-08 12:16:08 +01:00
|
|
|
+++ startproc.c 2009-12-07 14:15:44.487929547 +0000
|
2009-12-07 15:53:19 +01:00
|
|
|
@@ -41,7 +41,8 @@ static int do_start(const char *name, ch
|
|
|
|
static void closefds(FILE *not);
|
|
|
|
static void waiton(const char *list);
|
|
|
|
|
|
|
|
-static int quiet = 1, supprmsg = 0, sess = 0, seconds = 0, sigchld = 0, force = 0, dialog = 0;
|
|
|
|
+static int quiet = true, supprmsg = false, sess = false, seconds = false;
|
|
|
|
+static int sigchld = false, force = false, dialog = false;
|
|
|
|
static struct passwd *user = NULL;
|
|
|
|
static struct group *grp = NULL;
|
|
|
|
static int syslogd = 0;
|
|
|
|
@@ -54,7 +55,7 @@ static void (*save_sigquit) = SIG_DFL;
|
|
|
|
static void sig_quit(int nsig)
|
|
|
|
{
|
|
|
|
(void)signal(nsig, save_sigquit);
|
|
|
|
- signaled = 1;
|
|
|
|
+ signaled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sig_chld(int nsig)
|
|
|
|
@@ -113,10 +114,10 @@ int main(int argc, char **argv)
|
|
|
|
error(LSB_WRGSYN,"Option -c requires special root directory\n");
|
|
|
|
break;
|
|
|
|
case 'e':
|
|
|
|
- env = 1;
|
|
|
|
+ env = true;
|
|
|
|
break;
|
|
|
|
case 'd':
|
|
|
|
- dialog = 1;
|
|
|
|
+ dialog = true;
|
|
|
|
seconds = 15;
|
|
|
|
break;
|
|
|
|
case 'p': /* Former option -f */
|
|
|
|
@@ -129,7 +130,7 @@ int main(int argc, char **argv)
|
|
|
|
error(LSB_WRGSYN,"Option -p requires pid file to read pid from\n");
|
|
|
|
break;
|
|
|
|
case 'f': /* Newer option -f for force start (LSB specs!) */
|
|
|
|
- force++;
|
|
|
|
+ force = true;
|
|
|
|
break;
|
|
|
|
case 'l':
|
|
|
|
if (optarg && optarg[0] != '-' && !log_file) {
|
|
|
|
@@ -158,11 +159,11 @@ int main(int argc, char **argv)
|
|
|
|
error(LSB_WRGSYN,"Option -n requires nice level\n");
|
|
|
|
break;
|
|
|
|
case 'q':
|
|
|
|
- supprmsg = 1;
|
|
|
|
+ supprmsg = true;
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
if (sdaemon) goto fail;
|
|
|
|
- sess = 1;
|
|
|
|
+ sess = true;
|
|
|
|
break;
|
|
|
|
case 'u':
|
|
|
|
if (optarg && optarg[0] != '/' && optarg[0] != '-') {
|
|
|
|
@@ -288,7 +289,8 @@ int main(int argc, char **argv)
|
|
|
|
pid_file = (char*) xmalloc(DEFPIDLEN+strlen(basename)+1);
|
|
|
|
pid_file = strcat(strcat(strcpy(pid_file,DEFPIDDIR),basename),DEFPIDEXT);
|
|
|
|
}
|
|
|
|
- }
|
|
|
|
+ } else
|
|
|
|
+ force = true;
|
|
|
|
|
|
|
|
/* Check and verify the pid file */
|
|
|
|
errno = 0;
|
2009-12-08 12:16:08 +01:00
|
|
|
@@ -296,17 +298,25 @@ int main(int argc, char **argv)
|
|
|
|
if (errno != ENOENT)
|
|
|
|
warn("Can not stat %s: %s\n", pid_file, strerror(errno));
|
|
|
|
|
|
|
|
- /* No pid file means that we have to search in /proc/ */
|
2009-12-07 15:53:19 +01:00
|
|
|
free(pid_file);
|
|
|
|
pid_file = NULL;
|
|
|
|
+
|
|
|
|
+ if (force && errno == ENOENT)
|
|
|
|
+ goto force;
|
2009-12-08 12:16:08 +01:00
|
|
|
+
|
|
|
|
+ /* No pid file means that we have to search in /proc/ */
|
2009-12-07 15:53:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pid_file && !st.st_size) {
|
2009-12-08 12:16:08 +01:00
|
|
|
warn("Empty pid file %s for %s\n", pid_file, fullname);
|
|
|
|
|
|
|
|
- /* No pid file means that we have to search in /proc/ */
|
|
|
|
free(pid_file);
|
|
|
|
pid_file = NULL;
|
|
|
|
+
|
|
|
|
+ if (force)
|
|
|
|
+ goto force;
|
|
|
|
+
|
|
|
|
+ /* No pid file means that we have to search in /proc/ */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pid_file) { /* The case of having a pid file */
|
|
|
|
@@ -336,6 +346,8 @@ int main(int argc, char **argv)
|
|
|
|
|
|
|
|
/* Do main work */
|
|
|
|
if (!remember) { /* No process found with pid file */
|
|
|
|
+ if (force)
|
|
|
|
+ goto force;
|
|
|
|
if (pidof(fullname,root,flags) < 0)
|
|
|
|
exit(LSB_PROOFX);
|
|
|
|
clear_pids(); /* Remove all pids which should be ignored */
|