I must be missing something in the discussion about random numbers. Why does groff need them? In the offered example tmp="$d/eqn2graph$groff_rand" the "random number" serves only to make a (supposedly) unique name. But of course, if the number is truly random, it is not guaranteed to be unique. Why does groff not use the time-honored $$ to serve the purpose? The only requirement for an absolute guarantee of uniqueness is that the shell script whose pid $$ represents lives as long as the temporary file.
Doug McIlroy