Mercurial > hg > aboriginal
view sources/toys/unique-port.sh @ 1522:95a720e694a6
Switch x86_64 from nptl back to pthreads. This isn't the correct fix but uClibc apparently never tested nptl on x86-64, and one of the assembly files doesn't support PIC.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 10 May 2012 22:03:22 -0500 |
parents | 1cdd44f2bac2 |
children |
line wrap: on
line source
unique_port() { # Try to find an unused port number for each running instance of the program. START=8192 RANGE=$[$(awk '{print $1}' /proc/sys/net/ipv4/ip_local_port_range)-$START] if [ $RANGE -lt 8 ] then START=$[$(awk '{print $2}' /proc/sys/net/ipv4/ip_local_port_range)] RANGE=$[65535-$START] if [ $RANGE -lt 8 ] then START=16384 RANGE=32768 fi fi echo $[($$%$RANGE)+$START] }