Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

$PID/$$ capped at 32767?

by reinaldo.gomes (Beadle)
on Oct 30, 2017 at 23:00 UTC ( [id://1202385]=perlquestion: print w/replies, xml ) Need Help??

reinaldo.gomes has asked for the wisdom of the Perl Monks concerning the following question:

I wrote a Perl script and I've been trying to print its own PID, which works fine when it's 32767 or lower. However, it is always shown as 32767 whenever the real PID is above this number. It seems like it's a size/signing limitation for the variable. In MySQL, that would be equivalent to SMALLINT being signed (-32768 to +32767) as opposed to being unsigned (0 to 65535).

Any ideas on how to solve this?

EDIT: Just to explain my stupidity: the problem was exactly what I said in my original post: MySQL INT column being signed instead of unsigned. The value I was seeing came from a select, not from a print. MySQL was limiting this value, not Perl.

Replies are listed 'Best First'.
Re: $PID/$$ capped at 32767?
by choroba (Cardinal) on Oct 30, 2017 at 23:07 UTC
    What OS/$^O are you running? In mine (Linux), PID can never grow over 32767, it rotates back to 1 (300 in fact).

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
      So, I just realized that I can lower the 'kernel.max_pid' value to 32768, which would solve my problem. However, just for the sake of completeness, I would like to know if there is any configuration that I can change on Perl to increase the max PID value capacity.
        I would like to know if there is any configuration that I can change on Perl to increase the max PID value capacity

        I don't have an answer to that question, but perhaps you'll get to see the larger values by calling POSIX::getpid instead of $$.
        (This would require, of course, that the POSIX module be loaded.)

        Or there might be some other module that would return the larger values.

        Cheers,
        Rob

      Perl Version is: revision 5 version 16 subversion 3

      OS is: CentOS 7.3.1611 (Kernel 3.10.0-514.el7.x86_64)

      By issuing "top" command, I can see PIDs up to 62k+
        Are you using a 32 or 64 bit perl? ( perl -v )


        holli

        You can lead your users to water, but alas, you cannot drown them.
Re: $PID/$$ capped at 32767?
by reinaldo.gomes (Beadle) on Oct 31, 2017 at 13:22 UTC
    Just to explain my stupidity: the problem was exactly what I said in my original post: MySQL INT column being signed instead of unsigned. The value I was seeing came from a select, not from a print. MySQL was limiting this value, not Perl.
      That would do it :)

      Can you please edit the original post to indicate that?


      Mike
Re: $PID/$$ capped at 32767?
by choroba (Cardinal) on Oct 31, 2017 at 13:22 UTC
    What happens when you try to change $$ to such a high value?
    $$ = 64_000; print $$, "\n";
    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1202385]
Approved by Paladin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 17:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found