Skip to content

Commit

Permalink
Fix kill.def patch
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorTodorovskiIBM committed Oct 1, 2024
1 parent 43275cc commit 40fa788
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions stable-patches/kill.def.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/builtins/kill.def b/builtins/kill.def
index c1ea14b8..bf7d01c2 100644
index c655092..ae4e1c8 100644
--- a/builtins/kill.def
+++ b/builtins/kill.def
@@ -22,7 +22,7 @@ $PRODUCES kill.c
Expand All @@ -21,22 +21,22 @@ index c1ea14b8..bf7d01c2 100644
+ -K Sends a superkill signal to force the ending of a process.
+ A kill signal must be sent prior to sending the superkill signal.
+ -l list the signal names; if arguments follow `-l' they are
+ assumed to be signal numbers for which names should be listed
+ assumed to be signal numbers for which names should be listed
+ -L synonym for -l

Kill is a shell builtin for two reasons: it allows job IDs to be used
instead of process IDs, and allows processes to be killed if the limit
@@ -71,6 +73,7 @@ extern int errno;
#endif /* !errno */

static void kill_error (pid_t, int);
+static void kill_error2 (pid_t pid, int e, int e2);
static void kill_error PARAMS((pid_t, int));
+static void kill_error2 PARAMS((pid_t, int, int));

#if !defined (CONTINUE_AFTER_KILL_ERROR)
# define CONTINUE_OR_FAIL return (EXECUTION_FAILURE)
@@ -84,11 +87,13 @@ static void kill_error (pid_t, int);
int
kill_builtin (WORD_LIST *list)
@@ -85,11 +88,13 @@ int
kill_builtin (list)
WORD_LIST *list;
{
- int sig, any_succeeded, listing, saw_signal, dflags;
+ int sig, any_succeeded, listing, saw_signal, dflags, superkill_flag;
Expand All @@ -49,7 +49,7 @@ index c1ea14b8..bf7d01c2 100644
if (list == 0)
{
builtin_usage ();
@@ -111,6 +116,12 @@ kill_builtin (WORD_LIST *list)
@@ -112,6 +117,12 @@ kill_builtin (list)
listing++;
list = list->next;
}
Expand All @@ -62,26 +62,25 @@ index c1ea14b8..bf7d01c2 100644
else if (ISOPTION (word, 's') || ISOPTION (word, 'n'))
{
list = list->next;
@@ -192,8 +203,17 @@ use_sigspec:
if (*word && valid_number (list->word->word, &pid_value) && (pid_value == (pid_t)pid_value))
@@ -194,7 +205,16 @@ use_sigspec:
{
pid = (pid_t) pid_value;
+ /* If the superkill flag is set, call __superkill for each PID */
+ if (superkill_flag)
+ {
+ if (__superkill(pid) < 0)
+ {
+ kill_error2 (pid, errno, __errno2());
+ CONTINUE_OR_FAIL;
+ }
+ }

- if (kill_pid (pid, sig, pid < -1) < 0)
+ /* If the superkill flag is set, call __superkill for each PID */
+ if (superkill_flag)
+ {
+ if (__superkill(pid) < 0)
+ {
+ kill_error2 (pid, errno, __errno2());
+ CONTINUE_OR_FAIL;
+ }
+ }
+ else if (kill_pid (pid, sig, pid < -1) < 0)
{
if (errno == EINVAL)
sh_invalidsig (sigspec);
@@ -237,7 +257,17 @@ use_sigspec:
@@ -238,7 +258,17 @@ use_sigspec:

UNBLOCK_CHILD (oset);

Expand All @@ -100,7 +99,7 @@ index c1ea14b8..bf7d01c2 100644
{
if (errno == EINVAL)
sh_invalidsig (sigspec);
@@ -271,3 +301,21 @@ kill_error (pid_t pid, int e)
@@ -274,3 +304,21 @@ kill_error (pid, e)
x = _("Unknown error");
builtin_error ("(%ld) - %s", (long)pid, x);
}
Expand All @@ -114,11 +113,11 @@ index c1ea14b8..bf7d01c2 100644
+ if (x == 0)
+ x = _("Unknown error");
+
+if ((e== EINVAL) &&
+ ((e2 & 0x0000FFFF) == 1496)) {
+ builtin_error ("(%ld) - %s", (long)pid, "Cannot superkill without prior KILL signal to process.");
+ } else {
+ builtin_error ("(%ld) - %s - (ERRNO2: %x)", (long)pid, x, e2);
+ /* Needs a kill before superkill */
+ if ((e== EINVAL) &&
+ ((e2 & 0x0000FFFF) == 1496)) {
+ builtin_error ("(%ld) - %s", (long)pid, "Cannot superkill without prior KILL signal to process.");
+ } else {
+ builtin_error ("(%ld) - %s (errno2: %x)", (long)pid, x, e2);
+ }
+
+}

0 comments on commit 40fa788

Please sign in to comment.