output is not redirected when ps_mem is killed
This commit is contained in:
parent
a019b05753
commit
4030e62895
16
ps_mem.py
16
ps_mem.py
@ -78,6 +78,7 @@ import time
|
|||||||
import errno
|
import errno
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import io
|
||||||
|
|
||||||
# The following exits cleanly on Ctrl-C or EPIPE
|
# The following exits cleanly on Ctrl-C or EPIPE
|
||||||
# while treating other exceptions as before.
|
# while treating other exceptions as before.
|
||||||
@ -100,6 +101,16 @@ our_pid = os.getpid()
|
|||||||
|
|
||||||
have_pss = 0
|
have_pss = 0
|
||||||
|
|
||||||
|
class Unbuffered(io.TextIOBase):
|
||||||
|
def __init__(self, stream):
|
||||||
|
super().__init__()
|
||||||
|
self.stream = stream
|
||||||
|
def write(self, data):
|
||||||
|
self.stream.write(data)
|
||||||
|
self.stream.flush()
|
||||||
|
def close(self):
|
||||||
|
self.stream.close()
|
||||||
|
|
||||||
class Proc:
|
class Proc:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
uname = os.uname()
|
uname = os.uname()
|
||||||
@ -245,7 +256,7 @@ def getMemStats(pid):
|
|||||||
|
|
||||||
def getCmdName(pid, split_args):
|
def getCmdName(pid, split_args):
|
||||||
cmdline = proc.open(pid, 'cmdline').read().split("\0")
|
cmdline = proc.open(pid, 'cmdline').read().split("\0")
|
||||||
if cmdline[-1] == '' and len(cmdline) > 1:
|
while cmdline[-1] == '' and len(cmdline) > 1:
|
||||||
cmdline = cmdline[:-1]
|
cmdline = cmdline[:-1]
|
||||||
|
|
||||||
path = proc.path(pid, 'exe')
|
path = proc.path(pid, 'exe')
|
||||||
@ -454,6 +465,9 @@ def verify_environment():
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
sys.stdout = Unbuffered(sys.stdout)
|
||||||
|
sys.stderr = Unbuffered(sys.stderr)
|
||||||
|
|
||||||
split_args, pids_to_show, watch, only_total = parse_options()
|
split_args, pids_to_show, watch, only_total = parse_options()
|
||||||
verify_environment()
|
verify_environment()
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Name: ps_mem
|
Name: ps_mem
|
||||||
Version: 3.6
|
Version: 3.6
|
||||||
Release: 15%{?dist}
|
Release: 16%{?dist}
|
||||||
Summary: Memory profiling tool
|
Summary: Memory profiling tool
|
||||||
License: LGPLv2
|
License: LGPLv2
|
||||||
URL: https://github.com/pixelb/ps_mem
|
URL: https://github.com/pixelb/ps_mem
|
||||||
@ -46,6 +46,12 @@ install -Dpm644 %{name}.1 %{buildroot}%{_mandir}/man1/%{name}.1
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Feb 02 2022 Jan Rybar <jrybar@redhat.com> - 3.6-16
|
||||||
|
- output is not redirected when ps_mem is killed
|
||||||
|
- cmdline unwanted blank spaces fixed
|
||||||
|
- Resolves: rhbz#2033997
|
||||||
|
- Resolves: rhbz#2049743
|
||||||
|
|
||||||
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 3.6-15
|
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 3.6-15
|
||||||
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
|
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
|
||||||
Related: rhbz#1991688
|
Related: rhbz#1991688
|
||||||
|
Loading…
Reference in New Issue
Block a user