.RB [ \-k
.RB [ \-i ]
.RB [ \-M ]
+.RB [ \-w ]
.RB [ \- \fISIGNAL
] ]
.IR name " ..."
This is an invaluable seatbelt which prevents you from killing the machine
if \fINAME\fR happens to not be a filesystem.
.TP
+\fB\-w\fP
+Kill only processes which have write access. This option is
+silently ignored if \fB\-k\fP is not present too.
+.TP
\fB\-n \fISPACE\fR, \fB\-\-namespace\fR \fISPACE\fR
Select a different name space. The name spaces \fBfile\fR (file names, the
default), \fBudp\fR (local UDP ports), and \fBtcp\fR (local TCP ports) are
static uid_t getpiduid(const pid_t pid);
static int print_matches(struct names *names_head, const opt_type opts,
const int sig_number);
-static void kill_matched_proc(struct procs *pptr, const opt_type opts,
+static int kill_matched_proc(struct procs *pptr, const opt_type opts,
const int sig_number);
/*int parse_mount(struct names *this_name, struct device_list **dev_list);*/
" -SIGNAL send this signal instead of SIGKILL\n"
" -u,--user display user IDs\n"
" -v,--verbose verbose output\n"
+ " -w,--writeonly kill only processes with write access\n"
" -V,--version display version information\n"));
#ifdef WITH_IPV6
fprintf(stderr, _(
{"silent", 0, NULL, 's'},
{"user", 0, NULL, 'u'},
{"verbose", 0, NULL, 'v'},
+ {"writeonly", 0, NULL, 'w'},
{"version", 0, NULL, 'V'},
#ifdef WITH_IPV6
{"ipv4", 0, NULL, '4'},
case 'v':
opts |= OPT_VERBOSE;
break;
+ case 'w':
+ opts |= OPT_WRITE;
+ break;
case 'V':
print_version();
return 0;
int len = 0;
struct passwd *pwent = NULL;
int have_match = 0;
+ int have_kill = 0;
int name_has_procs;
for (nptr = names_head; nptr != NULL; nptr = nptr->next) {
}
} /* be silent */
if (opts & OPT_KILL)
- kill_matched_proc(nptr->matched_procs, opts,
- sig_number);
+ have_kill = kill_matched_proc(nptr->matched_procs,
+ opts, sig_number);
} /* next name */
return (have_match == 1 ? 0 : 1);
} /* while */
}
-static void
+static int
kill_matched_proc(struct procs *proc_head, const opt_type opts,
const int sig_number)
{
struct procs *pptr;
pid_t mypid;
+ int ret = 0;
mypid = getpid();
continue; /* dont kill myself */
if ( pptr->proc_type != PTYPE_NORMAL )
continue;
+ if ((opts & OPT_WRITE) && ((pptr->access & ACCESS_FILEWR) == 0))
+ continue;
if ((opts & OPT_INTERACTIVE) && (ask(pptr->pid) == 0))
continue;
if ( kill(pptr->pid, sig_number) < 0) {
fprintf(stderr, _("Could not kill process %d: %s\n"),
pptr->pid, strerror(errno));
+ continue;
}
+ ret = 1;
}
+ return ret;
}
static dev_t find_net_dev(void)