Pipe::Find - Find the processes behind the pipes that you open
This document describes version 0.04 of Pipe::Find (from Perl distribution Pipe-Find), released on 2016-03-05.
use Pipe::Find qw(find_pipe_processes get_stdout_pipe_process); $procs = find_pipe_processes(); # hashref, key=fd, value=process info hash if ($procs->{0}) { say "STDIN is connected to a pipe"; say "pid=$procs->{0}{pid}"; say "cmdline=$procs->{0}{cmdline}"; say "exe=$procs->{0}{exe}"; } if ($procs->{1}) { say "STDOUT is connected to a pipe"; ... } if ($procs->{2}) { say "STDERR is connected to a pipe"; ... } # ...
None exported by default, but they are exportable.
List all processes behind the pipes that your process opens. (You can also find pipes for another process by passing its PID.)
Currently only works on Linux. Works by listing /proc/$$/fd and selecting all fd's that symlinks to pipe:*. Then it will list all /proc/*/fd and find matching pipes.
/proc/$$/fd
pipe:*
/proc/*/fd
STDIN pipe is at fd 0, STDOUT pipe at fd 1, STDERR at fd 2.
Basically a shortcut to get the fd 0 only, since this is common. Return undef if STDIN is not piped.
If you plan on getting process information for both STDIN and STDOUT, it's better to use find_pipe_processes() than calling this function and get_stdout_pipe_process(), because the latter will scan twice.
find_pipe_processes()
get_stdout_pipe_process()
Basically a shortcut to get the fd 1 only, since this is common. Return undef if STDOUT is not piped.
If you plan on getting process information for both STDIN and STDOUT, it's better to use find_pipe_processes() than calling this function and get_stdin_pipe_process(), because the latter will scan twice.
get_stdin_pipe_process()
Please visit the project's homepage at https://metacpan.org/release/Pipe-Find.
Source repository is at https://github.com/perlancar/perl-Pipe-Find.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Pipe-Find
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2016 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Pipe::Find, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Pipe::Find
CPAN shell
perl -MCPAN -e shell install Pipe::Find
For more information on module installation, please visit the detailed CPAN module installation guide.