Perl::AfterFork - reinitializes Perl's notion of $$ and getppid()
use Perl::AfterFork; &Perl::AfterFork::reinit_pid; &Perl::AfterFork::reinit_ppid; &Perl::AfterFork::reinit_pidstatus; &Perl::AfterFork::reinit;
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.
fork()
fork
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.
getpid
$$
glibc
getpid(2)
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.
getppid(2)
Further Perl maintains an internal cache of spawned children for it's waitpid implementation.
waitpid
All these cached information can be reinitialized with this module.
reinitializes the PID-cache
reinitializes the PPID-cache
reinitializes the waitpid-cache
reinitializes all 3 at once
Not an Exporter.
Torsten Foertsch, <torsten.foertsch@gmx.net>
Copyright (C) 2005 by Torsten Foertsch
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.
To install Perl::AfterFork, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl::AfterFork
CPAN shell
perl -MCPAN -e shell install Perl::AfterFork
For more information on module installation, please visit the detailed CPAN module installation guide.