mirror of
https://github.com/webmin/webmin.git
synced 2026-09-19 20:10:38 +01:00
Sped up find_byname
This commit is contained in:
@@ -75,3 +75,4 @@ Requests to the /unauthenticated URL can never execute CGI programs, to provide
|
||||
Fixed XSS bugs in pam_login.cgi.
|
||||
---- Changes since 1.370 ----
|
||||
Hid the Jabber and Security Sentries modules by default, as the underlying software is no longer supported.
|
||||
On Linux systems, sped up the function for finding processes so that it no longer has to launch 'ps' - instead, it reads /proc directly.
|
||||
|
||||
@@ -924,6 +924,23 @@ else { return 0; }
|
||||
# Finds a process by name, and returns a list of matching PIDs
|
||||
sub find_byname
|
||||
{
|
||||
if ($gconfig{'os_type'} =~ /-linux$/ && -r "/proc/$$/cmdline") {
|
||||
# Linux with /proc filesystem .. use cmdline files, as this is
|
||||
# faster than forking
|
||||
local @pids;
|
||||
opendir(PROCDIR, "/proc");
|
||||
foreach my $f (readdir(PROCDIR)) {
|
||||
if ($f eq int($f)) {
|
||||
local $line = &read_file_contents("/proc/$f/cmdline");
|
||||
if ($line =~ /$_[0]/) {
|
||||
push(@pids, $f);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(PROCDIR);
|
||||
return @pids;
|
||||
}
|
||||
|
||||
if (&foreign_check("proc")) {
|
||||
# Call the proc module
|
||||
&foreign_require("proc", "proc-lib.pl");
|
||||
|
||||
Reference in New Issue
Block a user