logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Linux::Pid - Get the native PID and the PPID on Linux

Author

       Copyright (c) 2002-2007 Rafael Garcia-Suarez. All rights reserved. This program is free software; you can
       redistribute it and/or modify it under the same terms as Perl itself.

perl v5.40.0                                       2024-10-20                                           Pid(3pm)

Description

       Why should one use a module to get the PID and the PPID of a process where there are the $$ variable and
       the getppid() builtin ? (Not mentioning the equivalent POSIX::getpid() and POSIX::getppid() functions.)

       In fact, this is useful on Linux, with multithreaded programs. Linux' C library, using the linux thread
       model, returns different values of the PID and the PPID from different threads. (Other thread models such
       as NPTL don't have the same behaviour). This module forces perl to call the underlying C functions
       getpid() and getppid().

Name

       Linux::Pid - Get the native PID and the PPID on Linux

Synopsis

           use Linux::Pid;
           print Linux::Pid::getpid(), "\t", Linux::Pid::getppid(), "\n";

           use Linux::Pid qw(getpid getppid);
           print getpid(), "\t", getppid(), "\n";

See Also