1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
From 2c65c0550f5785674ae5e0b057ef2efc66358f27 Mon Sep 17 00:00:00 2001
From: Christian Garbs <mitch@cgarbs.de>
Date: Sun, 15 Mar 2020 20:36:49 +0100
Subject: fix parsing of ps output for PIDs longer than 5 digits
---
reniced | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/reniced b/reniced
index 656175e..6481c3c 100755
--- a/reniced
+++ b/reniced
@@ -2,7 +2,7 @@
#
# reniced - renice running processes based on regular expressions
#
-# Copyright (C) 2005 Christian Garbs <mitch@cgarbs.de>
+# Copyright (C) 2005, 2020 Christian Garbs <mitch@cgarbs.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -432,9 +432,10 @@ sub read_processes()
my $line = <PS>; # skip first line
while ($line = <PS>) {
chomp $line;
- my $pid = substr($line, 0, 5 )+ 0;
- my $cmd = substr($line, 6 );
- push @proc, { PID => $pid, CMD => $cmd };
+ if ($line =~ m/^\s*(\d+)\s+(.*)$/) {
+ my ($pid, $cmd) = ($1, $2);
+ push @proc, { PID => $pid, CMD => $cmd };
+ }
}
}
close PS or die "can't close `$cmdline': $!\n";
--
2.30.2
|