Perl::AfterFork - reinitializes Perl's notion of $$ and getppid()


Perl-AfterFork documentation Contained in the Perl-AfterFork distribution.

Index


Code Index:

NAME

Top

Perl::AfterFork - reinitializes Perl's notion of $$ and getppid()

SYNOPSIS

Top

  use Perl::AfterFork;
  &Perl::AfterFork::reinit_pid;
  &Perl::AfterFork::reinit_ppid;
  &Perl::AfterFork::reinit_pidstatus;
  &Perl::AfterFork::reinit;

DESCRIPTION

Top

Using Perl's fork() command or your libc's fork() function or even your operating system's fork syscall does not do the same thing.

Since a process' PID does not change during it's life time Perl caches the result of the getpid syscall using the once fetched PID each time $$ is used. Hence after a successful fork() the internal PID-cache must be invalidated. The same argument is valid for glibc. It caches the getpid(2) as well.

As for getppid(2), Perl is even caching that. In my opinion Perl is doing wrong when caching the getppid(2) result at all since it can change without further notice when the parent process dies.

Further Perl maintains an internal cache of spawned children for it's waitpid implementation.

All these cached information can be reinitialized with this module.

reinit_pid

reinitializes the PID-cache

reinit_ppid

reinitializes the PPID-cache

reinit_pidstatus

reinitializes the waitpid-cache

reinit

reinitializes all 3 at once

EXPORT

Top

Not an Exporter.

AUTHOR

Top

Torsten Foertsch, <torsten.foertsch@gmx.net>

COPYRIGHT AND LICENSE

Top


Perl-AfterFork documentation Contained in the Perl-AfterFork distribution.

package Perl::AfterFork;

use 5.008;
use strict;
use warnings;

our $VERSION = '0.01';

require XSLoader;
XSLoader::load('Perl::AfterFork', $VERSION);

# Preloaded methods go here.

1;
__END__
# Below is stub documentation for your module. You'd better edit it!