bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH] mktempd: silence dd usage


From: Eric Blake
Subject: [PATCH] mktempd: silence dd usage
Date: Thu, 1 Dec 2011 14:01:25 -0700

When running a testsuite on FreeBSD, I saw a lot of:

1+ records in
0+1 records out
10 bytes transferred in 0.000063 secs (158875 bytes/sec)

literring the testsuite, and traced it to the fact that we
were silencing one, but not the other, dd usage in our fallback.

* build-aux/mktempd (rand_bytes): Silence dd.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog         |    5 +++++
 build-aux/mktempd |    3 ++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fdf8b25..5a616e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,1 +1,6 @@
+2011-12-01  Eric Blake  <address@hidden>
+
+       mktempd: silence dd usage
+       * build-aux/mktempd (rand_bytes): Silence dd.
+
 2011-11-30  Simon Josefsson  <address@hidden>

        manywarnings: Don't mention gcc version in docstring.
diff --git a/build-aux/mktempd b/build-aux/mktempd
index 7a09a4b..b6360e4 100755
--- a/build-aux/mktempd
+++ b/build-aux/mktempd
@@ -30,35 +30,36 @@
 #      the desired directory.
 #  - make only $MAX_TRIES attempts

 ME=`basename "$0"`
 die() { echo >&2 "$ME: $@"; exit 1; }

 MAX_TRIES=4

 rand_bytes()
 {
   n=$1

   chars=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

   dev_rand=/dev/urandom
   if test -r "$dev_rand"; then
     # Note: 256-length($chars) == 194; 3 copies of $chars is 186 + 8 = 194.
-    dd ibs=$n count=1 if="$dev_rand" | tr -c $chars 01234567$chars$chars$chars
+    dd ibs=$n count=1 if="$dev_rand" 2>/dev/null \
+      | tr -c $chars 01234567$chars$chars$chars
     return
   fi

   cmds='date; date +%N; free; who -a; w; ps auxww; ps ef; netstat -n'
   data=` (eval "$cmds") 2>&1 | gzip `

   n_plus_50=`expr $n + 50`

   # Ensure that $data has length at least 50+$n
   while :; do
     len=`echo "$data"|wc -c`
     test $n_plus_50 -le $len && break;
     data=` (echo "$data"; eval "$cmds") 2>&1 | gzip `
   done

   echo "$data" \
     | dd bs=1 skip=50 count=$n 2>/dev/null \
-- 
1.7.7.3




reply via email to

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