Non-random PIDs

From: Jason Dixon (jason_at_dixongroup.net)
Date: 08/01/04

  • Next message: Jason Dixon: "Re: Non-random PIDs"
    To: Red Hat Mailing List <redhat-list@redhat.com>
    Date: Sun, 1 Aug 2004 15:21:37 -0400
    
    

    I remember reading a long time ago about how Linux doesn't randomize
    new process ID's, in the way that OpenBSD (among others, I hope) does.
    Is there anyone here who follows Linux kernel development closely that
    might know why this hasn't happened yet, or perhaps know when it will?

    If this is a feature of 2.6, please excuse my ignorance. My tests have
    all been performed on 2.4 kernels. Note that this behavior is also
    found on Mac OS X.

    Example fork.pl on Whitebox Linux (RHEL 3) running 2.4.21-15.0.3.ELsmp:

    [root@colo2 root]# while true; do perl fork.pl; sleep 1; done
    I'm the child and my pid is 21116. my parent is 21115
    I'm the parent and my pid is 21115. My child is 21116
    I'm the child and my pid is 21119. my parent is 21118
    I'm the parent and my pid is 21118. My child is 21119
    I'm the child and my pid is 21122. my parent is 21121
    I'm the parent and my pid is 21121. My child is 21122
    I'm the child and my pid is 21125. my parent is 21124
    I'm the parent and my pid is 21124. My child is 21125
    I'm the child and my pid is 21128. my parent is 21127
    I'm the parent and my pid is 21127. My child is 21128

    Example fork.pl on OpenBSD 3.4 -stable:

    bash-2.05b# while true; do perl fork.pl; sleep 1; done
    I'm the parent and my pid is 21142. My child is 11841
    I'm the child and my pid is 11841. my parent is 21142
    I'm the parent and my pid is 9919. My child is 13316
    I'm the child and my pid is 13316. my parent is 9919
    I'm the parent and my pid is 19968. My child is 4416
    I'm the child and my pid is 4416. my parent is 19968
    I'm the parent and my pid is 14416. My child is 8937
    I'm the child and my pid is 8937. my parent is 14416
    I'm the parent and my pid is 1940. My child is 917
    I'm the child and my pid is 917. my parent is 1940

    Thanks,

    --
    Jason Dixon, RHCE
    DixonGroup Consulting
    http://www.dixongroup.net
    -- 
    redhat-list mailing list
    unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
    https://www.redhat.com/mailman/listinfo/redhat-list
    

  • Next message: Jason Dixon: "Re: Non-random PIDs"

    Relevant Pages

    • Re: Killing a process that takes too long
      ... You may instead use fork and exec; this lets you use the process-ID to ... kill 'INT', $pid; ... and it does not guarantee that the child ... So we need a way to kill several processes of the process group of the parent, ...
      (perl.beginners)
    • Re: Killing a process that takes too long
      ... and it does not guarantee that the child ... You can test it by placing $$ (process pid) in the output of these two ... So we need a way to kill several processes of the process group of the parent, ...
      (perl.beginners)
    • Re: Creatng 100% separate process from Parent
      ... the "child" process still maintains its ... So another process could start with the same pid as the "parent" - should ... > configuration tool) is typically just run from the start menu. ...
      (microsoft.public.win32.programmer.kernel)
    • Re: optimize log parsing
      ... >> Hey Xho, I tried this: ... >> for the constructor is 0 then, assuming you're in the child process, ... >> called after the successful startup of a child in the parent process. ... >> - pid of the process which has been started ...
      (comp.lang.perl.misc)
    • Re: Is fork() hook ever possible?
      ... child's pid is needed. ... Currently OpenBSD does almost that checking getpid() every time ... the child? ... Calling getpidas OpenBSD ...
      (freebsd-current)