fork or exec thingy.

Terje Malmedal (terje.malmedal@usit.uio.no)
Thu, 22 Jul 1999 15:51:56 +0200 (MET DST)


Bash on Linux seems to have problems starting subprocesses occasionally, the
following program fails randomly:
--------------------------
#!/bin/bash
printf %5d 2
i=3

while /usr/bin/test $i -lt 10000 ; do
j=3
while /usr/bin/test $j -lt $i ; do
if /usr/bin/test `expr $i % $j` -eq 0 ; then
j=$i
fi
j=`expr $j + 2`
done
if /usr/bin/test $j -eq $i ; then
printf %5d $i
fi
i=`expr $i + 2 `
done
--------------------------

typical output:

# sh primes.sh
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859primes.sh: Can't reopen pipe to command substitution (fd 4): No child processes
/usr/bin/test: argument expected
/usr/bin/test: argument expected
primes.sh: Can't reopen pipe to command substitution (fd 4): No child processes
/usr/bin/test: argument expected
877 881 883 887 907 911 919 929 937 941 947 953 967 971 977 983

I've tested this on 2.2.6 2.2.6ac1 2.2.9 and 2.2.10ac10 with bash
versions 1.14 and 2.03.

Machines tested were idle apart from the shellscript, with plenty of RAM.

This does not happen on 2.0.36, nor does this happen in bash on
Solaris, Irix or Digital Unix.

-- 
 - Terje
malmedal@usit.uio.no

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/