Linux-Pid-0.04/0000755000175000017500000000000010633470257012523 5ustar rafaelrafaelLinux-Pid-0.04/t/0000755000175000017500000000000010633470257012766 5ustar rafaelrafaelLinux-Pid-0.04/t/threaded.t0000644000175000017500000000166310633467262014743 0ustar rafaelrafael#!perl -w BEGIN { unshift @INC, './lib'; } use strict; use warnings; use Config; BEGIN { if (!$Config{useithreads}) { print "1..0 # Skip: no ithreads\n"; exit 0; } } use Test::More tests => 9; use threads; use threads::shared; use_ok( 'Linux::Pid' ); my ($pid, $ppid) = (Linux::Pid::getpid(), Linux::Pid::getppid()); my $pid2 : shared = 0; my $ppid2 : shared = 0; new threads( sub { ($pid2, $ppid2) = (Linux::Pid::getpid(), Linux::Pid::getppid()); } )->join; ok( defined $pid, q/$pid defined/ ); ok( defined $ppid, q/$ppid defined/ ); ok( defined $pid2, q/$pid2 defined/ ); ok( defined $ppid2, q/$ppid2 defined/ ); ok( $pid, q/$pid non null/ ); ok( $pid2, q/$pid2 non null/ ); my $threadmodel = `getconf GNU_LIBPTHREAD_VERSION`; SKIP: { skip "thread model is $threadmodel", 2 unless $threadmodel =~ /linux/i; isn't( $pid, $pid2, q/$pid and $pid2 differ/ ); isn't( $ppid, $ppid2, q/$ppid and $ppid2 differ/ ); } Linux-Pid-0.04/t/basic.t0000644000175000017500000000035010633467262014234 0ustar rafaelrafael#!perl -w BEGIN { unshift @INC, './lib'; } use strict; use warnings; use Linux::Pid; print "1..2\n"; print "not " if $$ != Linux::Pid::getpid(); print "ok 1\n"; print "not " if getppid() != Linux::Pid::getppid(); print "ok 2\n"; Linux-Pid-0.04/t/import.t0000644000175000017500000000035110633467262014466 0ustar rafaelrafael#!perl -w BEGIN { unshift @INC, './lib'; } use strict; use warnings; use Linux::Pid qw(getpid getppid); print "1..2\n"; print "not " if $$ != getpid(); print "ok 1\n"; print "not " if CORE::getppid() != getppid(); print "ok 2\n"; Linux-Pid-0.04/Pid.xs0000644000175000017500000000043210633467646013622 0ustar rafaelrafael#include "EXTERN.h" #include "perl.h" #include "XSUB.h" /*#include "ppport.h"*/ MODULE = Linux::Pid PACKAGE = Linux::Pid int getpid() CODE: RETVAL = getpid(); OUTPUT: RETVAL int getppid() CODE: RETVAL = getppid(); OUTPUT: RETVAL Linux-Pid-0.04/META.yml0000644000175000017500000000044710633470257014001 0ustar rafaelrafael# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Linux-Pid version: 0.04 version_from: Pid.pm installdirs: site requires: distribution_type: module generated_by: ExtUtils::MakeMaker version 6.30_01 Linux-Pid-0.04/Changes0000644000175000017500000000035010633470072014007 0ustar rafaelrafaelRevision history for Perl module Linux::Pid. 0.04 Jun 12 2007 Move to an XS implementation, courtesy of Kevin M. Goess 0.03 Wed Aug 18 Skip tests on NPTL. 0.02 Thu Sep 12 Prettification. 0.01 Fri Aug 9 original version Linux-Pid-0.04/MANIFEST0000644000175000017500000000024310633467657013665 0ustar rafaelrafaelMANIFEST Changes README Makefile.PL Pid.pm Pid.xs t/basic.t t/import.t t/threaded.t META.yml Module meta-data (added by MakeMaker) Linux-Pid-0.04/Pid.pm0000644000175000017500000000265210633467532013604 0ustar rafaelrafaelpackage Linux::Pid; use strict; use warnings; our $VERSION = 0.04; require XSLoader; XSLoader::load('Linux::Pid', $VERSION); sub import { shift; my $p = caller; for my $symbol (@_) { if ($symbol eq 'getpid' or $symbol eq 'getppid') { no strict 'refs'; *{$p."::".$symbol} = \&{$symbol}; } else { require Carp; Carp::croak("Unrecognized symbol $symbol"); } } } 1; __END__ =head1 NAME Linux::Pid - Get the native PID and the PPID on Linux =head1 SYNOPSIS use Linux::Pid; print Linux::Pid::getpid(), "\t", Linux::Pid::getppid(), "\n"; use Linux::Pid qw(getpid getppid); print getpid(), "\t", getppid(), "\n"; =head1 DESCRIPTION Why should one use a module to get the PID and the PPID of a process where there are the C<$$> variable and the C builtin ? (Not mentioning the equivalent C and C 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 C and C. =head1 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. =cut Linux-Pid-0.04/README0000644000175000017500000000062310633467700013403 0ustar rafaelrafaelLinux::Pid version 0.04 ======================= Returns what Linux' C library thinks the PID and PPID are. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install COPYRIGHT AND LICENCE This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Copyright (C) 2002-2007 Rafael Garcia-Suarez Linux-Pid-0.04/Makefile.PL0000644000175000017500000000017110633467611014474 0ustar rafaelrafaeluse ExtUtils::MakeMaker; WriteMakefile( 'NAME' => 'Linux::Pid', 'VERSION_FROM' => 'Pid.pm', # finds $VERSION );