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 fixed typo in es.po
* Mark Hindley cleaned up translation code in src/Makefile. * Mark Hindley cleaned up translation code in src/Makefile.
* Drop sulogin from Debian build. Removed libcrypt-dev dependency. * Drop sulogin from Debian build. Removed libcrypt-dev dependency.

View File

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