[LTP] [PATCH v3] scripts: Dump /proc and /sys
Cyril Hrubis
chrubis@suse.cz
Tue Dec 12 11:20:48 CET 2017
Hi!
> +
> +for i in $(seq $nproc); do
> + mkfifo "$dump_dir/fifo$i"
> + ( spawn_dd ) < "$dump_dir/fifo$i" &
> +done
> +
> +count=$nproc
> +for f in $files; do
> + if [ $count -gt 0 ]; then
> + count=$((count - 1))
> + else
> + count=$nproc
> + fi
> + echo "$f" > "$dump_dir/fifo$count"
> +done
We still do have off-by-one here. The fifos are created for $(seq
$nproc) which starts at 1 but the count here goes to 0 so instead of
writing to fifo some we will write to a regular file here for
$count == 0.
Why not just:
count=$nproc
for f in $files; do
count=$((count - 1))
if [ $count -lt 1 ]; then
count=$nproc
fi
...
done
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list