[Top][All Lists]

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

Re: avoid mktemp/mkstemp internally

From: Chet Ramey
Subject: Re: avoid mktemp/mkstemp internally
Date: Mon, 16 May 2016 10:02:33 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:45.0) Gecko/20100101 Thunderbird/45.0

On 5/13/16 2:40 PM, Mike Frysinger wrote:
> i was pointed at a bug report for FreeBSD systems [1] where running lots
> of processes in parallel would randomly fail with errors like:
>   cannot make pipe for process substitution: File exists
> upstream FreeBSD addressed this by defining USE_MKTEMP [2] & USE_MKSTEMP
> [3] when building bash.  looking at the source in bash though, i can't
> see why these aren't always defined.  why does bash try to reimplement
> both funcs ad-hoc instead of just using the stable/guaranteed system
> versions ?

Because many traditional implementations of mktemp/mkstemp suck.

> the bash versions seem like it's pretty trivial to collide: it mixes
> current seconds count, current pid number, and a counter. 

Not quite; the calls in bash mix in the return value from the system's
random().  Now, if that sucks too, you're going to lose.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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