The killall5 command now avoids sending any signals,

including SIGSTOP and SIGCONT, to processes on the omit list.
This commit is contained in:
Jesse 2023-02-19 00:42:55 -04:00
parent 8e04d9ce2c
commit bd55f5e243
2 changed files with 24 additions and 13 deletions

View File

@ -1,4 +1,8 @@
sysvinit (3.06) unreleased; urgency=low
sysvinit (3.07) released; urgency=low
* Fixed killall5 so that processes in the omit list are
not sent any signals, including SIGSTOP.
sysvinit (3.06) released; urgency=low
* Mark Hindley fixed typo in es.po
* Mark Hindley cleaned up translation code in src/Makefile.
* Drop sulogin from Debian build. Removed libcrypt-dev dependency.

View File

@ -120,16 +120,16 @@ typedef struct _s_nfs
} NFS;
/* List of processes. */
PROC *plist;
PROC *plist = NULL;
/* List of processes to omit. */
OMIT *omit;
OMIT *omit = NULL;
/* List of NFS mountes partitions. */
NFS *nlist;
NFS *nlist = NULL;
/* Did we stop all processes ? */
int sent_sigstop;
int sent_sigstop = 0;
int scripts_too = 0;
/* Should pidof try to list processes in I/O wait (D) and zombie (Z) states? */
@ -1152,19 +1152,25 @@ int main(int argc, char **argv)
/* lock us into memory */
mlockall(MCL_CURRENT | MCL_FUTURE);
/* Now stop all processes. */
/* Get our session ID and PID to make sure we do not kill ourselves or our session. */
sid = (int)getsid(0);
pid = (int)getpid();
/* Now stop all processes, unless there are some we should omit. */
if (! omit)
{
kill(-1, SIGSTOP);
sent_sigstop = 1;
}
/* Read /proc filesystem */
if (readproc() < 0) {
if (sent_sigstop)
kill(-1, SIGCONT);
return(1);
}
/* Now kill all processes except init (pid 1) and our session. */
sid = (int)getsid(0);
pid = (int)getpid();
for (p = plist; p; p = p->next) {
if (p->pid == 1 || p->pid == pid || p->sid == sid || p->kernel)
continue;
@ -1179,13 +1185,14 @@ int main(int argc, char **argv)
/* On a match, continue with the for loop above. */
if (optr)
continue;
}
} /* end of skipping PIDs to omit */
kill(p->pid, sig);
retval = 0;
}
/* And let them continue. */
if (sent_sigstop)
kill(-1, SIGCONT);
/* Done. */