Proc::Info::Environment CPAN Module
Perl
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib/Proc/Info
t
.gitignore
Changes
MANIFEST
MANIFEST.SKIP
Makefile.PL
README

README

######################################################################
    Proc::Info::Environment 0.01
######################################################################

NAME
    Proc::Info::Environment - Read Environment Variables of any Process

SYNOPSIS
        use Proc::Info::Environment;
        my $proc_info = Proc::Info::Environment->new();

        my $env = $proc_info->env( $pid );

        print "\$PATH of process $pid is $env->{PATH}\n";

DESCRIPTION
    Proc::Info::Environment retrieves the settings of environment variables
    in arbitrary running processes of the operating system.

    For example,

        use Proc::Info::Environment;
        my $proc_env = Proc::Info::Environment->new();
        my $env = $proc_env->env( 123 );

    will retrieve the environment settings of the process with the pid 123
    and (if this process exists and is readable by the user) return them as
    a hash reference in $env.

    As an illustrative (but not very useful) example, retrieving

        my $env = $proc_env->env( $$ );

    will return a reference to a hash similar to %ENV, which contains the
    environment variables of the current process.

    Reading other processes' environment variables is only possible if the
    operating system (a) supports a method to do this and (b) the user of
    the currently running process is either root, or has the same uid as the
    process whose variables it wants to read.

    Proc::Info::Environment is currently supported only for specific Unix
    systems. On Linux, it will use the procfs file system mounted under
    /proc to get the information needed. It will read the file
    /proc/xxx/environ, where xxx is the pid of the target process.

    To verify if Proc::Info::Environment supports your operating system, run
    Proc::Info::Environment::os_supported(), which returns a true value if
    it is supported. If the OS is unsupported, the new() constructor will
    die() with an error message listing all currently supported operating
    systems.

    The module's architecture allows for easy support of other systems, if
    you want support for one and know how the information is provided, drop
    me an email.

LEGALESE
    Copyright 2010 by Mike Schilli, all rights reserved. This program is
    free software, you can redistribute it and/or modify it under the same
    terms as Perl itself.

AUTHOR
    2010, Mike Schilli <cpan@perlmeister.com>