@@ -1,5 +1,10 @@
Revision history for Perl extension BSD::Process
+0.07 2013-06-22 13:37:32 UTC
+ - The args method is now implemented (thanks to az5112 on github).
+ - The module compiles correctly on FreeBSD 9.x
+ - Improved module metadata (Kwalitee)
+
0.06 2011-04-10 19:06:52 UTC
- Interact correctly with the CPAN toolchain, and fix a test
error.
@@ -0,0 +1,6 @@
+LICENSE FOR BSD-Process
+
+Copyright © 2006-2013 David Landgren.
+
+This distribution is free software; you can redistribute it and/or
+modify it under the Artistic License v2.
@@ -1,4 +1,5 @@
Changes
+LICENSE
MANIFEST
MANIFEST.SKIP
Makefile.PL
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: BSD-Process
-version: 0.06
+version: 0.07
abstract: Information about running processes on BSD platforms
author:
- David Landgren
@@ -12,6 +12,7 @@ build_requires:
ExtUtils::MakeMaker: 0
requires:
Class::Accessor: 0.25
+ perl: 5.008001
XSLoader: 0
no_index:
directory:
@@ -33,4 +33,5 @@ WriteMakefile(
'XSLoader' => 0,
'Class::Accessor' => '0.25',
},
+ MIN_PERL_VERSION => '5.008001'
);
@@ -1,6 +1,6 @@
# BSD::Process.pm
#
-# Copyright (c) 2006-2011 David Landgren
+# Copyright (c) 2006-2013 David Landgren
# All rights reserved
package BSD::Process;
@@ -13,7 +13,7 @@ use XSLoader;
use base qw(Class::Accessor);
use vars qw($VERSION @ISA @EXPORT_OK);
-$VERSION = '0.06';
+$VERSION = '0.07';
@ISA = qw(Exporter Class::Accessor);
@EXPORT_OK = (qw(process_info process_list P));
@@ -304,8 +304,8 @@ BSD::Process - Information about running processes on BSD platforms
=head1 VERSION
-This document describes version 0.06 of BSD::Process,
-released 2011-04-10.
+This document describes version 0.07 of BSD::Process,
+released 2013-06-22.
=head1 SYNOPSIS
@@ -607,8 +607,16 @@ B<F6> means the method returns something useful for FreeBSD
=item process_args, args
-The command line arguments passed to the program. CURRENTLY
-UNIMPLEMENTED.
+The command with all its arguments as a string. When the process
+args are unavailable, the name of the executable in brackets is
+returned (same as in the F<ps> program). This may happen when the
+length of the arguments exceeds the kernel limit set with the
+C<kern.ps_arg_cache_limit> kernel setting. This is usually 256, for
+more information check the manual page for the F<sysctl> program.
+
+If you have the companion C<BSD::Sysctl> module installed, you can
+check this with C<print sysctl("kern.ps_arg_cache_limit");> or else
+with the C<sysctl(8)> command.
=item process_pid, pid
@@ -1087,9 +1095,8 @@ version.
=head1 NOTES
-Currently, FreeBSD versions 4 through 7 are supported (and 8
-probably works out of the box). Support for NetBSD and OpenBSD may
-be added in future versions.
+Currently, FreeBSD versions 4 through 8 are supported. Support for
+NetBSD and OpenBSD may be added in future versions.
=head1 SEE ALSO
@@ -1125,9 +1132,6 @@ Information about current processes on the Win32 platform.
=head1 BUGS
-Process arguments are not handled (current attempts result in
-coredumps).
-
Not all of the ps(1) keywords are implemented. At the worst,
this (currently) means that you could not rewrite it in Perl.
This may be addressed in a future release.
@@ -1140,13 +1144,20 @@ Make sure you include the output from the following two commands:
perl -MBSD::Process -le 'print $BSD::Process::VERSION'
perl -V
+I also accept pull requests on Github. See
+L<https://github.com/dland/BSD-Process>
+
=head1 ACKNOWLEDGEMENTS
-None.
+The FreeBSD Ports team, for their work on keeping this module up
+to date on the ports tree. Their efforts are greatly appreciated.
+
+Thanks also to az5112 on Github (I've lost their name), who implemented
+the C<args> method.
=head1 AUTHOR
-David Landgren, copyright (C) 2006-2011. All rights reserved.
+David Landgren, copyright (C) 2006-2013. All rights reserved.
http://www.landgren.net/perl/
@@ -1,3 +1,5 @@
+/* Process.xs -- part of the Perl BSD::Process distribution */
+
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
@@ -245,22 +247,25 @@ HV *_procinfo (struct kinfo_proc *kp, int resolve) {
}
if( argv && *argv ) {
-#ifdef NEVER
len = strlen(*argv);
+
argsv = newSVpvn(*argv, len);
while (*++argv) {
sv_catpvn(argsv, " ", 1);
sv_catpvn(argsv, *argv, strlen(*argv));
- len += strlen(*argv)+1;
}
- hv_store(h, "args", 4, argsv, 0);
-#else
- hv_store(h, "args", 4, newSVpvn("", 0), 0);
-#endif
}
else {
- hv_store(h, "args", 4, newSVpvn("", 0), 0);
+ /* sometimes the process args may be unavailable; when this happens the name
+ * of the executable in brackets is returned, similar to the ps program.
+ */
+ argsv = newSVpvn("[", 1);
+ sv_catpvn(argsv, kp->COMM_FIELD, strlen(kp->COMM_FIELD));
+ sv_catpvn(argsv, "]", 1);
}
+
+ hv_store(h, "args", 4, argsv, 0);
+
if (kd) {
kvm_close(kd);
}
@@ -287,7 +292,9 @@ HV *_procinfo (struct kinfo_proc *kp, int resolve) {
hv_store(h, "advlock", 7, newSViv(NO_FREEBSD_4x(P_FLAG(P_ADVLOCK))), 0);
hv_store(h, "controlt", 8, newSViv(NO_FREEBSD_4x(P_FLAG(P_CONTROLT))), 0);
hv_store(h, "kthread", 7, newSViv(NO_FREEBSD_4x(P_FLAG(P_KTHREAD))), 0);
+#if __FreeBSD_version < 802501
hv_store(h, "noload", 6, newSViv(NO_FREEBSD_4x(P_FLAG(P_NOLOAD))), 0);
+#endif
hv_store(h, "ppwait", 6, newSViv(NO_FREEBSD_4x(P_FLAG(P_PPWAIT))), 0);
hv_store(h, "profil", 6, newSViv(NO_FREEBSD_4x(P_FLAG(P_PROFIL))), 0);
hv_store(h, "stopprof", 8, newSViv(NO_FREEBSD_4x(P_FLAG(P_STOPPROF))), 0);
@@ -1,4 +1,4 @@
-The file is the README for BSD::Process version 0.06
+The file is the README for BSD::Process version 0.07
INSTALLATION
@@ -62,13 +62,14 @@ me a line.
I will send you my public key for connecting via ssh. All I need
is a shell and a C compiler, and I give you my word that I will not
-do anything evil. If required, I will connect only from a fixed
-address (which would allow you to set up an AllowUsers USER@HOST
+do anything evil. I will connect only from a fixed address or
+addresses (which would allow you to set up an AllowUsers USER@HOST
rule in your sshd_config file).
STATUS
-This module is under active development.
+This module is under active development. Contributions welcome via
+github. See https://github.com/dland/BSD-Process
AUTHOR
@@ -76,7 +77,7 @@ David Landgren
COPYRIGHT
-This module is copyright (C) David Landgren 2006-2007.
+This module is copyright (C) David Landgren 2006-2013.
All rights reserved.
LICENSE