bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

$RANDOM incorrectly seeded in subshells


From: Tomas Janousek
Subject: $RANDOM incorrectly seeded in subshells
Date: Fri, 9 Nov 2007 11:01:51 +0100
User-agent: Mutt/1.5.16 (2007-06-09)

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -g -O2
uname output: Linux tjanouse.englab.brq.redhat.com 2.6.18-8.1.8.el5 #1 SMP Mon 
Jun 25 17:06:19 EDT 2007 i686 i686 i386 GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 3.2
Patch Level: 25
Release Status: release

Description:
        If you cause rng to be seeded in a subshell (enclose the command in
        parentheses) and in this same subshell spawn another subshell, rng is
        not seeded as it should be. See the example in Repeat-by.

Repeat-By:
        $ ( echo $RANDOM; ( echo $RANDOM ); ( echo $RANDOM ) )
        28804
        3664
        3664

Fix:
        We had a fix in the Fedora package that used subshell_level instead of
        just looking at subshell_environment, but that introduced another
        oddity, since subshell_level is not increased for simple async
        commands.
        (bugzilla for this one is
        https://bugzilla.redhat.com/show_bug.cgi?id=344411 )

        I'm attaching a patch that was applied over that one, so it just shows
        what the final solution is like, it's not applicable to 3.2 tarball.

-- 
Tomas Janousek, SW Engineer, Red Hat, Inc.

Attachment: bash-3.2-344411.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]