Hello community, here is the log from the commit of package perl-Proc-ProcessTable for openSUSE:Factory checked in at 2018-02-09 15:47:12 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Proc-ProcessTable (Old) and /work/SRC/openSUSE:Factory/.perl-Proc-ProcessTable.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Proc-ProcessTable" Fri Feb 9 15:47:12 2018 rev:11 rq:573957 version:0.55 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Proc-ProcessTable/perl-Proc-ProcessTable.changes 2015-08-29 20:04:41.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Proc-ProcessTable.new/perl-Proc-ProcessTable.changes 2018-02-09 15:47:13.916067969 +0100 @@ -1,0 +2,6 @@ +Wed Feb 7 17:10:15 UTC 2018 - co...@suse.com + +- updated to 0.55 + see /usr/share/doc/packages/perl-Proc-ProcessTable/Changes + +------------------------------------------------------------------- Old: ---- Proc-ProcessTable-0.53.tar.gz New: ---- Proc-ProcessTable-0.55.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Proc-ProcessTable.spec ++++++ --- /var/tmp/diff_new_pack.QqrD3o/_old 2018-02-09 15:47:14.640041972 +0100 +++ /var/tmp/diff_new_pack.QqrD3o/_new 2018-02-09 15:47:14.640041972 +0100 @@ -1,7 +1,7 @@ # # spec file for package perl-Proc-ProcessTable # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: perl-Proc-ProcessTable -Version: 0.53 +Version: 0.55 Release: 0 #Upstream: Artistic-1.0 or GPL-1.0+ %define cpan_name Proc-ProcessTable @@ -25,7 +25,7 @@ License: (Artistic-1.0 or GPL-1.0+) and GPL-2.0 Group: Development/Libraries/Perl Url: http://search.cpan.org/dist/Proc-ProcessTable/ -Source0: http://www.cpan.org/authors/id/J/JW/JWB/%{cpan_name}-%{version}.tar.gz +Source0: https://cpan.metacpan.org/authors/id/J/JW/JWB/%{cpan_name}-%{version}.tar.gz Source1: cpanspec.yml BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl @@ -37,7 +37,7 @@ %prep %setup -q -n %{cpan_name}-%{version} -find . -type f -print0 | xargs -0 chmod 644 +find . -type f ! -name \*.pl -print0 | xargs -0 chmod 644 %build %{__perl} Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}" @@ -53,6 +53,6 @@ %files -f %{name}.files %defattr(-,root,root,755) -%doc Changes PORTING README README.aix README.bsdi README.cygwin README.darwin README.dec_osf README.freebsd-kvm README.freebsd-procfs README.hpux README.linux README.netbsd README.openbsd README.solaris README.sunos README.unixware TODO +%doc Changes PORTING README README.aix README.bsdi README.cygwin README.darwin README.dec_osf README.freebsd-kvm README.freebsd-procfs README.hpux README.linux README.netbsd README.openbsd README.solaris README.sunos README.unixware %changelog ++++++ Proc-ProcessTable-0.53.tar.gz -> Proc-ProcessTable-0.55.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/Killall.pm new/Proc-ProcessTable-0.55/Killall.pm --- old/Proc-ProcessTable-0.53/Killall.pm 2015-08-23 11:57:06.000000000 +0200 +++ new/Proc-ProcessTable-0.55/Killall.pm 2017-02-21 01:03:40.000000000 +0100 @@ -49,7 +49,7 @@ $self = 0 unless defined $self; my $nkilled = 0; croak("killall: Unsupported signal: $signal") unless is_sig($signal); - my $t = new Proc::ProcessTable; + my $t = Proc::ProcessTable->new; my $BANG = undef; foreach my $p (@{$t->table}) { my $cmndline = $p->{cmndline} || $p->{fname}; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/MANIFEST new/Proc-ProcessTable-0.55/MANIFEST --- old/Proc-ProcessTable-0.53/MANIFEST 2015-08-24 21:35:47.000000000 +0200 +++ new/Proc-ProcessTable-0.55/MANIFEST 2018-02-01 23:02:42.000000000 +0100 @@ -24,6 +24,7 @@ Process/Process.pm hints/linux.pl hints/solaris.pl +hints/dragonfly.pl hints/aix.pl hints/aix_4_2.pl hints/aix_4_3.pl diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/META.json new/Proc-ProcessTable-0.55/META.json --- old/Proc-ProcessTable-0.53/META.json 2015-08-24 21:35:47.000000000 +0200 +++ new/Proc-ProcessTable-0.55/META.json 2018-02-01 23:02:41.000000000 +0100 @@ -4,7 +4,7 @@ "Jonathan Swartz <swa...@pobox.com>" ], "dynamic_config" : 1, - "generated_by" : "ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.150001", + "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], @@ -43,5 +43,6 @@ "url" : "https://github.com/jwbargsten/perl-proc-processtable" } }, - "version" : "0.53" + "version" : "0.55", + "x_serialization_backend" : "JSON::PP version 2.27400_02" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/META.yml new/Proc-ProcessTable-0.55/META.yml --- old/Proc-ProcessTable-0.53/META.yml 2015-08-24 21:35:47.000000000 +0200 +++ new/Proc-ProcessTable-0.55/META.yml 2018-02-01 23:02:41.000000000 +0100 @@ -7,7 +7,7 @@ configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 -generated_by: 'ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.150001' +generated_by: 'ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -22,4 +22,5 @@ Storable: '0' resources: repository: https://github.com/jwbargsten/perl-proc-processtable -version: '0.53' +version: '0.55' +x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/Process/Process.pm new/Proc-ProcessTable-0.55/Process/Process.pm --- old/Proc-ProcessTable-0.53/Process/Process.pm 2015-08-23 11:57:06.000000000 +0200 +++ new/Proc-ProcessTable-0.55/Process/Process.pm 2017-02-21 01:03:44.000000000 +0100 @@ -45,6 +45,7 @@ ######################################################## sub kill { my ($self, $signal) = @_; + die "PID " . $self->pid . " not valid." unless($self->pid =~ /^-?\d+$/); return( kill($signal, $self->pid) ); } @@ -178,6 +179,6 @@ =head1 SEE ALSO -Proc::ProcessTable.pm, perl(1). +L<Proc::ProcessTable>, L<perl(1)>. =cut diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/ProcessTable.pm new/Proc-ProcessTable-0.55/ProcessTable.pm --- old/Proc-ProcessTable-0.53/ProcessTable.pm 2015-08-24 21:34:37.000000000 +0200 +++ new/Proc-ProcessTable-0.55/ProcessTable.pm 2018-02-01 23:02:07.000000000 +0100 @@ -5,7 +5,6 @@ use strict; use warnings; use Carp; -use Fcntl; use Config; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD); @@ -19,7 +18,7 @@ @EXPORT = qw( ); -$VERSION = '0.53'; +$VERSION = '0.55'; sub AUTOLOAD { # This AUTOLOAD is used to 'autoload' constants from the constant() @@ -111,15 +110,25 @@ else { $self->_get_tty_list; - my $old_umask = umask; - umask 022; - sysopen( my $ttydevs_fh, $TTYDEVSFILE, O_WRONLY | O_EXCL | O_CREAT ) - or die "$TTYDEVSFILE was created by other process"; + require File::Temp; + require File::Basename; + + my($ttydevs_fh, $ttydevs_tmpfile) = File::Temp::tempfile('ProcessTable_XXXXXXXX', DIR => File::Basename::dirname($TTYDEVSFILE)); + chmod 0644, $ttydevs_tmpfile; Storable::store_fd( \%Proc::ProcessTable::TTYDEVS, $ttydevs_fh ); close $ttydevs_fh; - umask $old_umask; + if( !rename $ttydevs_tmpfile, $TTYDEVSFILE ) + { + my $err = $!; + unlink $ttydevs_tmpfile; + if( !-r $TTYDEVSFILE) + { + die "Renaming $ttydevs_tmpfile to $TTYDEVSFILE failed: $err"; + } + # else somebody else obviously created the file in the meantime + } } } else @@ -169,9 +178,9 @@ use Proc::ProcessTable; - $p = new Proc::ProcessTable( 'cache_ttys' => 1 ); - @fields = $p->fields; - $ref = $p->table; + my $p = Proc::ProcessTable->new( 'cache_ttys' => 1 ); + my @fields = $p->fields; + my $ref = $p->table; =head1 DESCRIPTION @@ -225,10 +234,10 @@ # A cheap and sleazy version of ps use Proc::ProcessTable; - $FORMAT = "%-6s %-10s %-8s %-24s %s\n"; - $t = new Proc::ProcessTable; + my $FORMAT = "%-6s %-10s %-8s %-24s %s\n"; + my $t = Proc::ProcessTable->new; printf($FORMAT, "PID", "TTY", "STAT", "START", "COMMAND"); - foreach $p ( @{$t->table} ){ + foreach my $p ( @{$t->table} ){ printf($FORMAT, $p->pid, $p->ttydev, @@ -241,11 +250,11 @@ # Dump all the information in the current process table use Proc::ProcessTable; - $t = new Proc::ProcessTable; + my $t = Proc::ProcessTable->new; - foreach $p (@{$t->table}) { + foreach my $p (@{$t->table}) { print "--------------------------------\n"; - foreach $f ($t->fields){ + foreach my $f ($t->fields){ print $f, ": ", $p->{$f}, "\n"; } } @@ -262,7 +271,7 @@ =head1 SEE ALSO -Proc::ProcessTable::Process.pm, perl(1). +L<Proc::ProcessTable::Process>, L<perl(1)>. =cut diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/ProcessTable.xs new/Proc-ProcessTable-0.55/ProcessTable.xs --- old/Proc-ProcessTable-0.53/ProcessTable.xs 2013-12-05 22:02:09.000000000 +0100 +++ new/Proc-ProcessTable-0.55/ProcessTable.xs 2018-02-01 18:58:10.000000000 +0100 @@ -101,6 +101,8 @@ /* This gets called by OS-specific get_table */ /* format specifies what types are being passed in, in a string */ /* containing these specifiers: */ +/* A ignore this array of strings */ +/* a array of strings, delimated with NULL, next argument is len */ /* S ignore this string */ /* s string */ /* I ignore this int */ @@ -146,6 +148,27 @@ key = *fields; switch(*format) { + case 'A': /* ignore; creates an undef value for this key in the hash */ + va_arg(args, char *); + va_arg(args, int); + hv_store(myhash, key, strlen(key), &PL_sv_undef, 0); + break; + case 'a': /* string */ + s_val = va_arg(args, char *); + i_val = va_arg(args, int); + { + int len; + char *s; + AV *av = newAV(); + + for (s = s_val; s < (s_val + i_val); s += len + 1) { + len = strlen(s); + av_push (av, newSVpvn (s, len)); + } + hv_store (myhash, key, strlen(key), newRV_noinc((SV *) av), 0); + } + break; + case 'S': /* ignore; creates an undef value for this key in the hash */ va_arg(args, char *); hv_store(myhash, key, strlen(key), newSV(0), 0); @@ -317,7 +340,7 @@ /* Check that we have an actual object. calling Proc::Processtable->table SIGSEVs - calling on an actual object is valid my $proc_obj = new Proc::ProcessTable; $proc_obj->table; + calling on an actual object is valid my $proc_obj = Proc::ProcessTable->new; $proc_obj->table; */ if (!obj || !SvOK (obj) || !SvROK (obj) || !sv_isobject (obj)) { croak("Must call table from an initalized object created with new"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/README new/Proc-ProcessTable-0.55/README --- old/Proc-ProcessTable-0.53/README 2013-04-04 21:14:47.000000000 +0200 +++ new/Proc-ProcessTable-0.55/README 2017-02-21 01:03:40.000000000 +0100 @@ -55,15 +55,15 @@ With this module, you can do things like this: - # kill memory pigs - use Proc::ProcessTable; + # kill memory pigs + use Proc::ProcessTable; - $t = new Proc::ProcessTable; - foreach $p ( @{$t->table} ){ - if( $p->pctmem > 95 ){ - $p->kill(9); - } - } + my $t = Proc::ProcessTable->new; + foreach my $p ( @{$t->table} ) { + if( $p->pctmem > 95 ){ + $p->kill(9); + } + } There is another short example in the file "example.pl" in the distribution. For a more elaborate example (in German), see diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/README.freebsd-kvm new/Proc-ProcessTable-0.55/README.freebsd-kvm --- old/Proc-ProcessTable-0.53/README.freebsd-kvm 2013-02-24 20:08:13.000000000 +0100 +++ new/Proc-ProcessTable-0.55/README.freebsd-kvm 2018-01-27 09:27:42.000000000 +0100 @@ -8,6 +8,7 @@ groups array of group ids pgrp process GID sess process session ID + jid Jail ID flags P_* flags sflags PS_* flags @@ -18,6 +19,7 @@ ctime running child time (in seconds) cutime child user time (in seconds) cstime child system time (in seconds) + pctcpu percent CPU usage wchan current system call state state of process diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/README.openbsd new/Proc-ProcessTable-0.55/README.openbsd --- old/Proc-ProcessTable-0.53/README.openbsd 2012-10-21 16:15:53.000000000 +0200 +++ new/Proc-ProcessTable-0.55/README.openbsd 2018-01-27 09:27:42.000000000 +0100 @@ -12,6 +12,8 @@ utime user time stime system time start time process started +size virtual memory size (bytes) +rss resident set size (bytes) fname command name state state of process ttydev path of process' tty diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/contrib/pswait new/Proc-ProcessTable-0.55/contrib/pswait --- old/Proc-ProcessTable-0.53/contrib/pswait 2012-10-21 16:15:53.000000000 +0200 +++ new/Proc-ProcessTable-0.55/contrib/pswait 2017-02-21 01:03:40.000000000 +0100 @@ -4,7 +4,7 @@ exit if ( $#ARGV == -1 ); $|++; -my $ptable = new Proc::ProcessTable; +my $ptable = Proc::ProcessTable->new; my %waited = (); my %proc; $proc{ $_->pid }=$_->fname foreach (@{$ptable->table}); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/example.pl new/Proc-ProcessTable-0.55/example.pl --- old/Proc-ProcessTable-0.53/example.pl 2012-10-21 16:15:53.000000000 +0200 +++ new/Proc-ProcessTable-0.55/example.pl 2017-02-21 01:03:40.000000000 +0100 @@ -2,15 +2,15 @@ use Proc::ProcessTable; -$ref = new Proc::ProcessTable; +my $ref = Proc::ProcessTable->new; -foreach $proc (@{$ref->table}) { +foreach my $proc (@{$ref->table}) { if(@ARGV) { next unless grep {$_ == $proc->{pid}} @ARGV; } print "--------------------------------\n"; - foreach $field ($ref->fields){ + foreach my $field ($ref->fields){ print $field, ": ", $proc->{$field}, "\n"; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/hints/dragonfly.pl new/Proc-ProcessTable-0.55/hints/dragonfly.pl --- old/Proc-ProcessTable-0.53/hints/dragonfly.pl 1970-01-01 01:00:00.000000000 +0100 +++ new/Proc-ProcessTable-0.55/hints/dragonfly.pl 2018-02-01 23:01:26.000000000 +0100 @@ -0,0 +1 @@ +symlink "os/FreeBSD.c", "OS.c" || die "Could not link os/FreeBSD.c to os/OS.c\n"; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/os/FreeBSD-kvm.c new/Proc-ProcessTable-0.55/os/FreeBSD-kvm.c --- old/Proc-ProcessTable-0.53/os/FreeBSD-kvm.c 2015-08-23 11:57:06.000000000 +0200 +++ new/Proc-ProcessTable-0.55/os/FreeBSD-kvm.c 2018-01-27 09:27:42.000000000 +0100 @@ -41,6 +41,7 @@ char cstime[20]; char flag[20]; char sflag[20]; + char pctcpu[20]; static char format[128]; char cmndline[ARG_MAX]; @@ -80,9 +81,11 @@ argv = kvm_getargv(kd, (const struct kinfo_proc *) &(procs[i]) , 0); if (argv) { int j = 0; - while (argv[j] && strlen(cmndline) <= ARG_MAX) { + while (argv[j] && strlen(cmndline)+strlen(argv[j])+1 <= ARG_MAX) { strcat(cmndline, argv[j]); - strcat(cmndline, " "); + if (argv[j+1]) { + strcat(cmndline, " "); + } j++; } } @@ -134,6 +137,24 @@ oncpu = procs[i].ki_oncpu == 0xff ? &PL_sv_undef : newSViv(procs[i].ki_oncpu); + /* get the current CPU percent usage for this process */ + /* copied from FreeBSD sources bin/ps/ps.c and friends */ + #define fxtofl(fixpt) ((double)(fixpt) / fscale) + int fscale; + size_t oldlen; + fixpt_t ccpu; + oldlen = sizeof(ccpu); + if (sysctlbyname("kern.ccpu", &ccpu, &oldlen, NULL, 0) == -1) + ppt_croak("cannot get kern.ccpu"); + if (sysctlbyname("kern.fscale", &fscale, &oldlen, NULL, 0) == -1) + ppt_croak("cannot get kern.fscale"); + double pcpu; + if (procs[i].ki_swtime == 0 || (procs[i].ki_flag & P_INMEM) == 0) + pcpu = 0.0; + else + pcpu = (100.0 * fxtofl(procs[i].ki_pctcpu) / (1.0 - exp(procs[i].ki_swtime * log(fxtofl(ccpu))))); + sprintf(pctcpu,"%.1f",pcpu); + bless_into_proc( format, Fields, @@ -157,6 +178,7 @@ ctime, cutime, cstime, + pctcpu, procs[i].ki_wmesg, state, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/os/FreeBSD-kvm.h new/Proc-ProcessTable-0.55/os/FreeBSD-kvm.h --- old/Proc-ProcessTable-0.53/os/FreeBSD-kvm.h 2015-08-23 11:57:06.000000000 +0200 +++ new/Proc-ProcessTable-0.55/os/FreeBSD-kvm.h 2018-01-27 09:27:42.000000000 +0100 @@ -13,7 +13,7 @@ /* We need to pass in a cap for ignore, lower for store on object */ /* We can just lc these! */ -static char Defaultformat[] = "iiiiiiiissssssssssssissiiiiiiiiiiiiiiVV"; +static char Defaultformat[] = "iiiiiiiisssssssssssssissiiiiiiiiiiiiiiVV"; /* Mapping of field to type */ static char* Fields[] = { @@ -36,6 +36,7 @@ "ctime", "cutime", "cstime", + "pctcpu", "wchan", "state", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/os/Linux.c new/Proc-ProcessTable-0.55/os/Linux.c --- old/Proc-ProcessTable-0.53/os/Linux.c 2015-08-24 21:24:37.000000000 +0200 +++ new/Proc-ProcessTable-0.55/os/Linux.c 2018-02-01 20:30:36.000000000 +0100 @@ -30,10 +30,10 @@ /* some static values that won't change, */ static pthread_once_t globals_init = PTHREAD_ONCE_INIT; -static long long boot_time; -static unsigned page_size; -static unsigned long long system_memory; -static unsigned system_hertz; +static long long boot_time; +static unsigned page_size; +static unsigned long long system_memory; +static unsigned system_hertz; static bool init_failed = false; @@ -66,7 +66,7 @@ boot_time = -1; system_memory = -1; - page_size = getpagesize(); + page_size = getpagesize(); /* initilize our mem stack, tempoary memory */ obstack_init(&mem_pool); @@ -433,12 +433,40 @@ field_enable(format_str, F_CMNDLINE); } +static void get_proc_cmdline(char *pid, char *format_str, struct procstat* prs, + struct obstack *mem_pool) +{ + char *cmdline_text, *cur; + off_t cmdline_off; + + if ((cmdline_text = read_file(pid, "cmdline", &cmdline_off, mem_pool)) == NULL) + return; + + prs->cmdline = cmdline_text; + prs->cmdline_len = cmdline_off; + field_enable(format_str, F_CMDLINE); +} + +static void get_proc_environ(char *pid, char *format_str, struct procstat* prs, + struct obstack *mem_pool) +{ + char *environ_text, *cur; + off_t environ_off; + + if ((environ_text = read_file(pid, "environ", &environ_off, mem_pool)) == NULL) + return; + + prs->environ = environ_text; + prs->environ_len = environ_off; + field_enable(format_str, F_ENVIRON); +} + static void get_proc_status(char *pid, char *format_str, struct procstat* prs, struct obstack *mem_pool) { char *status_text, *loc; off_t status_len; - int dummy_i; + int dummy_i; if ((status_text = read_file(pid, "status", &status_len, mem_pool)) == NULL) return; @@ -464,10 +492,13 @@ } else if (strncmp(loc, "Gid:", 4) == 0) { sscanf(loc + 4, " %d %d %d %d", &dummy_i, &prs->egid, &prs->sgid, &prs->fgid); field_enable_range(format_str, F_EGID, F_FGID); + } else if (strncmp(loc, "TracerPid:", 10) == 0) { + sscanf(loc + 10, " %d", &prs->tracer); + field_enable(format_str, F_TRACER); } /* short circuit condition */ - if (islower(format_str[F_EUID]) && islower(format_str[F_EGID])) + if (islower(format_str[F_EUID]) && islower(format_str[F_EGID]) && islower(format_str[F_TRACER])) goto done; } @@ -520,6 +551,9 @@ case 't': prs->state = get_string(TRACINGSTOP); break; + case 'P': + prs->state = get_string(PARKED); + break; /* unknown state, state is already set to NULL */ default: ppt_warn("Ran into unknown state (hex char: %x)", (int) prs->state_c); @@ -539,14 +573,14 @@ prs->cstime = JIFFIES_TO_MICROSECONDS(prs->cstime); prs->cutime = JIFFIES_TO_MICROSECONDS(prs->cutime); - /* derived time values */ - prs->time = prs->utime + prs->stime; - prs->ctime = prs->cutime + prs->cstime; + /* derived time values */ + prs->time = prs->utime + prs->stime; + prs->ctime = prs->cutime + prs->cstime; - field_enable_range(format_str, F_TIME, F_CTIME); + field_enable_range(format_str, F_TIME, F_CTIME); - /* fix rss to be in bytes (returned from kernel in pages) */ - prs->rss *= page_size; + /* fix rss to be in bytes (returned from kernel in pages) */ + prs->rss *= page_size; } /* calc_prec() @@ -661,8 +695,14 @@ /* correct values (times) found in /proc/${pid}/stat */ fixup_stat_values(format_str, prs); - /* get process' cmndline */ - get_proc_cmndline(dir_result->d_name, format_str, prs, &mem_pool); + /* get process' cmndline */ + get_proc_cmndline(dir_result->d_name, format_str, prs, &mem_pool); + + /* get process' cmdline */ + get_proc_cmdline(dir_result->d_name, format_str, prs, &mem_pool); + + /* get process' environ */ + get_proc_environ(dir_result->d_name, format_str, prs, &mem_pool); /* get process' cwd & exec values from the symblink */ eval_link(dir_result->d_name, "cwd", F_CWD, &prs->cwd, format_str, @@ -673,8 +713,8 @@ /* scapre from /proc/{$pid}/status */ get_proc_status(dir_result->d_name, format_str, prs, &mem_pool); - /* calculate precent cpu & mem values */ - calc_prec(format_str, prs, &mem_pool); + /* calculate precent cpu & mem values */ + calc_prec(format_str, prs, &mem_pool); /* Go ahead and bless into a perl object */ /* Linux.h defines const char* const* Fiels, but we cast it away, as bless_into_proc only understands char** */ @@ -701,8 +741,8 @@ prs->vsize, prs->rss, prs->wchan, - prs->time, - prs->ctime, + prs->time, + prs->ctime, prs->state, prs->euid, prs->suid, @@ -714,7 +754,12 @@ prs->pctmem, prs->cmndline, prs->exec, - prs->cwd + prs->cwd, + prs->cmdline, + prs->cmdline_len, + prs->environ, + prs->environ_len, + prs->tracer ); /* we want a new prs, for the next itteration */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/os/Linux.h new/Proc-ProcessTable-0.55/os/Linux.h --- old/Proc-ProcessTable-0.53/os/Linux.h 2013-12-05 21:47:33.000000000 +0100 +++ new/Proc-ProcessTable-0.55/os/Linux.h 2018-02-01 20:30:16.000000000 +0100 @@ -6,59 +6,65 @@ /* it also gets used by init_static_vars at the way top of the file, * I wanted init_static_vars to be at the way top close to the global vars */ static char *read_file(const char *path, const char *extra_path, off_t *len, - struct obstack *mem_pool); + struct obstack *mem_pool); struct procstat { - /* user/group id of the user running it */ - int uid; - int gid; - /* values scraped from /proc/{$pid}/stat */ - pid_t pid; - char comm[16]; /* limit in kernel, likewise in procps */ - char state_c; - int ppid; - int pgrp; - int sid; - int tty; - unsigned flags; - unsigned long minflt, cminflt, majflt, cmajflt; - unsigned long long utime, stime; - long long cutime, cstime; - long priority; - unsigned long long start_time; - unsigned long vsize; - long rss; - unsigned long wchan; - /* these are derived from above time values */ - unsigned long long time, ctime; - /* from above state_c but fixed up elsewhere */ - const char *state; - /* values scraped from /proc/{$pid}/status */ - int euid, suid, fuid; - int egid, sgid, fgid; - /* cwd, cmdline & exec files; values allocated at the end of obstacks */ - char *cwd; - char *cmndline; - char *exec; - /* other values */ - char pctcpu[LENGTH_PCTCPU]; /* precent cpu, without '%' char */ - char pctmem[sizeof("100.00")]; /* precent memory, without '%' char */ + /* user/group id of the user running it */ + int uid; + int gid; + /* values scraped from /proc/{$pid}/stat */ + pid_t pid; + char comm[16]; /* limit in kernel, likewise in procps */ + char state_c; + int ppid; + int pgrp; + int sid; + int tracer; + int tty; + unsigned flags; + unsigned long minflt, cminflt, majflt, cmajflt; + unsigned long long utime, stime; + long long cutime, cstime; + long priority; + unsigned long long start_time; + unsigned long vsize; + long rss; + unsigned long wchan; + /* these are derived from above time values */ + unsigned long long time, ctime; + /* from above state_c but fixed up elsewhere */ + const char *state; + /* values scraped from /proc/{$pid}/status */ + int euid, suid, fuid; + int egid, sgid, fgid; + /* cwd, cmdline & exec files; values allocated at the end of obstacks */ + char *cwd; + char *cmndline; + char *cmdline; + int cmdline_len; + char *environ; + int environ_len; + char *exec; + /* other values */ + char pctcpu[LENGTH_PCTCPU]; /* precent cpu, without '%' char */ + char pctmem[sizeof("100.00")]; /* precent memory, without '%' char */ }; enum state { - SLEEP, - WAIT, - RUN, - IDLE, - DEFUNCT, - STOP, - UWAIT, + SLEEP, + WAIT, + RUN, + IDLE, + DEFUNCT, + STOP, + UWAIT, DEAD, WAKEKILL, - TRACINGSTOP + TRACINGSTOP, + PARKED }; @@ -67,250 +73,264 @@ static const char strings[] = { /* process state */ - "sleep\0" - "wait\0" - "run\0" - "idle\0" - "defunct\0" + "sleep\0" + "wait\0" + "run\0" + "idle\0" + "defunct\0" "stop\0" "uwait\0" "dead\0" "wakekill\0" "tracingstop\0" /* error messages */ - "/proc unavailable\0" - "intilization failed\0" + "/proc unavailable\0" + "intilization failed\0" /* fields */ - "uid\0" - "gid\0" - "pid\0" - "fname\0" - "ppid\0" - "pgrp\0" - "sess\0" - "ttynum\0" - "flags\0" - "minflt\0" - "cminflt\0" - "majflt\0" - "cmajflt\0" - "utime\0" - "stime\0" - "cutime\0" - "cstime\0" - "priority\0" - "start\0" - "size\0" - "rss\0" - "wchan\0" - "time\0" - "ctime\0" - "state\0" - "euid\0" - "suid\0" - "fuid\0" - "egid\0" - "sgid\0" - "fgid\0" - "pctcpu\0" - "pctmem\0" - "cmndline\0" - "exec\0" - "cwd\0" + "uid\0" + "gid\0" + "pid\0" + "fname\0" + "ppid\0" + "pgrp\0" + "sess\0" + "ttynum\0" + "flags\0" + "minflt\0" + "cminflt\0" + "majflt\0" + "cmajflt\0" + "utime\0" + "stime\0" + "cutime\0" + "cstime\0" + "priority\0" + "start\0" + "size\0" + "rss\0" + "wchan\0" + "time\0" + "ctime\0" + "state\0" + "euid\0" + "suid\0" + "fuid\0" + "egid\0" + "sgid\0" + "fgid\0" + "pctcpu\0" + "pctmem\0" + "cmndline\0" + "exec\0" + "cwd\0" + "cmdline\0" + "environ\0" + "tracer\0" /* format string */ - "IIISIIIILLLLLJJJJIJPLLJJSIIIIIISSSSS\0" + "IIISIIIILLLLLJJJJIJPLLJJSIIIIIISSSSSAAI\0" }; - -static const size_t strings_index[] = -{ /* I generated this array with a perl script processing the above char array, - * and then performed cross string optimization (by hand) for: - * pid, time, uid, gid, minflt, majflt, + * and then performed cross string optimization (by hand) for: + * pid, time, uid, gid, minflt, majflt, */ -/* process status strings */ - 0, - 6, - 11, - 15, - 20, - 28, - 33, - 39, - 44, - 53, -/* error messages */ - 65, - 83, -/* fields */ - 103, - 107, - 111, - 115, - 121, - 126, - 131, - 136, - 143, - 149, - 156, - 164, - 171, - 179, - 185, - 191, - 198, - 205, - 214, - 220, - 225, - 229, - 235, - 240, - 246, - 252, - 257, - 262, - 267, - 272, - 277, - 282, - 289, - 296, - 305, - 310, -/* default format string (pre lower casing) */ - 314, +static const size_t strings_index[] = +{ + /* process status strings */ + 0, + 6, + 11, + 15, + 20, + 28, + 33, + 39, + 44, + 53, + /* error messages */ + 65, + 83, + /* fields */ + 103, + 107, + 111, + 115, + 121, + 126, + 131, + 136, + 143, + 149, + 156, + 164, + 171, + 179, + 185, + 191, + 198, + 205, + 214, + 220, + 225, + 229, + 235, + 240, + 246, + 252, + 257, + 262, + 267, + 272, + 277, + 282, + 289, + 296, + 305, + 310, + 314, + 322, + 330, + /* default format string (pre lower casing) */ + 337 }; enum string_name { - /* NOTE: we start this enum at 10, so we can use still keep using the - * state enum, and have those correspond to the static strings */ + /* NOTE: we start this enum at 10, so we can use still keep using the + * state enum, and have those correspond to the static strings */ /* error messages */ - STR_ERR_PROC_STATFS = 10, - STR_ERR_INIT, + STR_ERR_PROC_STATFS = 10, + STR_ERR_INIT, /* fields */ - STR_FIELD_UID, - STR_FIELD_GID, - STR_FIELD_PID, - STR_FIELD_FNAME, - STR_FIELD_PPID, - STR_FIELD_PGRP, - STR_FIELD_SESS, - STR_FIELD_TTYNUM, - STR_FIELD_FLAGS, - STR_FIELD_MINFLT, - STR_FIELD_CMINFLT, - STR_FIELD_MAJFLT, - STR_FIELD_CMAJFLT, - STR_FIELD_UTIME, - STR_FIELD_STIME, - STR_FIELD_CUTIME, - STR_FIELD_CSTIME, - STR_FIELD_PRIORITY, - STR_FIELD_START, - STR_FIELD_SIZE, - STR_FIELD_RSS, - STR_FIELD_WCHAN, - STR_FIELD_TIME, - STR_FIELD_CTIME, - STR_FIELD_STATE, - STR_FIELD_EUID, - STR_FIELD_SUID, - STR_FIELD_FUID, - STR_FIELD_EGID, - STR_FIELD_SGID, - STR_FIELD_FGID, - STR_FIELD_PCTCPU, - STR_FIELD_PCTMEM, - STR_FIELD_CMNDLINE, - STR_FIELD_EXEC, - STR_FIELD_CWD, + STR_FIELD_UID, + STR_FIELD_GID, + STR_FIELD_PID, + STR_FIELD_FNAME, + STR_FIELD_PPID, + STR_FIELD_PGRP, + STR_FIELD_SESS, + STR_FIELD_TTYNUM, + STR_FIELD_FLAGS, + STR_FIELD_MINFLT, + STR_FIELD_CMINFLT, + STR_FIELD_MAJFLT, + STR_FIELD_CMAJFLT, + STR_FIELD_UTIME, + STR_FIELD_STIME, + STR_FIELD_CUTIME, + STR_FIELD_CSTIME, + STR_FIELD_PRIORITY, + STR_FIELD_START, + STR_FIELD_SIZE, + STR_FIELD_RSS, + STR_FIELD_WCHAN, + STR_FIELD_TIME, + STR_FIELD_CTIME, + STR_FIELD_STATE, + STR_FIELD_EUID, + STR_FIELD_SUID, + STR_FIELD_FUID, + STR_FIELD_EGID, + STR_FIELD_SGID, + STR_FIELD_FGID, + STR_FIELD_PCTCPU, + STR_FIELD_PCTMEM, + STR_FIELD_CMNDLINE, + STR_FIELD_EXEC, + STR_FIELD_CWD, + STR_FIELD_CMDLINE, + STR_FIELD_ENIVORN, + STR_FIELD_TRACER, /* format string */ - STR_DEFAULT_FORMAT + STR_DEFAULT_FORMAT }; enum field { - F_UID, - F_GID, - F_PID, - F_FNAME, - F_PPID, - F_PGRP, - F_SESS, - F_TTYNUM, - F_FLAGS, - F_MINFLT, - F_CMINFLT, - F_MAJFLT, - F_CMAJFLT, - F_UTIME, - F_STIME, - F_CUTIME, - F_CSTIME, - F_PRIORITY, - F_START, - F_SIZE, - F_RSS, - F_WCHAN, - F_TIME, - F_CTIME, - F_STATE, - F_EUID, - F_SUID, - F_FUID, - F_EGID, - F_SGID, - F_FGID, - F_PCTCPU, - F_PCTMEM, - F_CMNDLINE, - F_EXEC, - F_CWD + F_UID, + F_GID, + F_PID, + F_FNAME, + F_PPID, + F_PGRP, + F_SESS, + F_TTYNUM, + F_FLAGS, + F_MINFLT, + F_CMINFLT, + F_MAJFLT, + F_CMAJFLT, + F_UTIME, + F_STIME, + F_CUTIME, + F_CSTIME, + F_PRIORITY, + F_START, + F_SIZE, + F_RSS, + F_WCHAN, + F_TIME, + F_CTIME, + F_STATE, + F_EUID, + F_SUID, + F_FUID, + F_EGID, + F_SGID, + F_FGID, + F_PCTCPU, + F_PCTMEM, + F_CMNDLINE, + F_EXEC, + F_CWD, + F_CMDLINE, + F_ENVIRON, + F_TRACER }; static const char* const field_names[] = { - strings + 103, - strings + 107, - strings + 111, - strings + 115, - strings + 121, - strings + 126, - strings + 131, - strings + 136, - strings + 143, - strings + 149, - strings + 156, - strings + 164, - strings + 171, - strings + 179, - strings + 185, - strings + 191, - strings + 198, - strings + 205, - strings + 214, - strings + 220, - strings + 225, - strings + 229, - strings + 235, - strings + 240, - strings + 246, - strings + 252, - strings + 257, - strings + 262, - strings + 267, - strings + 272, - strings + 277, - strings + 282, - strings + 289, - strings + 296, - strings + 305, - strings + 310, + strings + 103, + strings + 107, + strings + 111, + strings + 115, + strings + 121, + strings + 126, + strings + 131, + strings + 136, + strings + 143, + strings + 149, + strings + 156, + strings + 164, + strings + 171, + strings + 179, + strings + 185, + strings + 191, + strings + 198, + strings + 205, + strings + 214, + strings + 220, + strings + 225, + strings + 229, + strings + 235, + strings + 240, + strings + 246, + strings + 252, + strings + 257, + strings + 262, + strings + 267, + strings + 272, + strings + 277, + strings + 282, + strings + 289, + strings + 296, + strings + 305, + strings + 310, + strings + 314, + strings + 322, + strings + 330 }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/os/OpenBSD.c new/Proc-ProcessTable-0.55/os/OpenBSD.c --- old/Proc-ProcessTable-0.53/os/OpenBSD.c 2013-02-19 00:46:02.000000000 +0100 +++ new/Proc-ProcessTable-0.55/os/OpenBSD.c 2018-01-27 09:27:42.000000000 +0100 @@ -24,11 +24,13 @@ #include <time.h> #include <unistd.h> +void ppt_croak(const char *pat, ...); + /* No need for the procstat structure since we don't use /proc */ /* We need to pass in a cap for ignore, lower for store on object */ /* We can just lc these! */ -static char Defaultformat[] = "liiiiiiiiiiiissss"; +static char Defaultformat[] = "liiiiiiiiiiiillssss"; /* Mapping of field to type */ static char* Fields[] = { @@ -45,12 +47,14 @@ "utime", "stime", "start", + "size", + "rss", "fname", "state", "ttydev", "cmndline" }; -#define F_LASTFIELD 16 +#define F_LASTFIELD 18 /* Set up simple bounds checking */ #define STRLCPY(num,targ,src) if (strlcpy(targ,src,sizeof(targ)) >= sizeof(targ)) \ @@ -73,6 +77,8 @@ int i, argcount; int ttynum; long start; + unsigned long vsize; + unsigned long rss; char *ttydev; char cmndline[ARG_MAX+1]; char **pargv; @@ -123,14 +129,19 @@ break; } + vsize = getpagesize() * (procs[i].p_vm_dsize + procs[i].p_vm_ssize + procs[i].p_vm_tsize); + rss = getpagesize() * procs[i].p_vm_rssize; + /* arguments */ cmndline[0] = '\0'; pargv = kvm_getargv(kd, (const struct kinfo_proc *) &(procs[i]), 0); if (pargv) { argcount = 0; - while (pargv[argcount] && strlen(cmndline) <= ARG_MAX) { + while (pargv[argcount] && strlen(cmndline)+strlen(pargv[argcount])+1 <= ARG_MAX) { STRLCAT(1,cmndline,pargv[argcount]); - STRLCAT(2,cmndline," "); + if (pargv[argcount+1]) { + STRLCAT(2,cmndline," "); + } argcount++; } } @@ -151,6 +162,8 @@ procs[i].p_uutime_sec, procs[i].p_ustime_sec, procs[i].p_ustart_sec, + vsize, + rss, procs[i].p_comm, state, ttydev, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/os/aix.c new/Proc-ProcessTable-0.55/os/aix.c --- old/Proc-ProcessTable-0.53/os/aix.c 2012-10-21 16:15:53.000000000 +0200 +++ new/Proc-ProcessTable-0.55/os/aix.c 2017-02-21 01:03:40.000000000 +0100 @@ -107,7 +107,7 @@ format[F_STAT] = 'S'; } - + // http://www.thp.uni-due.de/pstree/pstree.c if ( state == ZOMBIE || getuser(&pr_buff[i], sizeof(struct procinfo), &uinfo, sizeof(struct userinfo) ) < 0 ) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/os/bsdi.c new/Proc-ProcessTable-0.55/os/bsdi.c --- old/Proc-ProcessTable-0.53/os/bsdi.c 2015-08-23 11:57:06.000000000 +0200 +++ new/Proc-ProcessTable-0.55/os/bsdi.c 2017-02-21 01:03:40.000000000 +0100 @@ -153,9 +153,11 @@ argv = kvm_getargv(kd, (const struct kinfo_proc *) &(procs[i]) , 0); if (argv) { int j = 0; - while (argv[j] && strlen(cmndline) <= MAXARGLN) { + while (argv[j] && strlen(cmndline)+strlen(argv[j])+1 <= MAXARGLN) { strcat(cmndline, argv[j]); - strcat(cmndline, " "); + if (argv[j+1]) { + strcat(cmndline, " "); + } j++; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Proc-ProcessTable-0.53/t/process.t new/Proc-ProcessTable-0.55/t/process.t --- old/Proc-ProcessTable-0.53/t/process.t 2012-10-21 16:15:53.000000000 +0200 +++ new/Proc-ProcessTable-0.55/t/process.t 2017-02-21 01:03:40.000000000 +0100 @@ -13,7 +13,7 @@ $SIG{CHLD} = sub{wait;}; my ( $got, $field ); -my $t = new Proc::ProcessTable; +my $t = Proc::ProcessTable->new; # Is there a process called cron foreach $got ( @{$t->table} )