[Top][All Lists]

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

Re: mktemp: not found

From: Eric Blake
Subject: Re: mktemp: not found
Date: Mon, 05 Dec 2011 06:59:25 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0

On 12/04/2011 12:57 PM, Jim Meyering wrote:
>> -  d=`unset TMPDIR; mktemp -d -t -p "$destdir_" "$template_" 2>/dev/null` \
>> +  d=`unset TMPDIR; (mktemp -d -t -p "$destdir_" "$template_") 2>/dev/null` \
> Thanks.  That would avoid the spurious output.
> How about using { ...; } instead?
>   d=`unset TMPDIR; { mktemp -d -t -p "$destdir_" "$template_"; } 2>/dev/null` 
> \
> That should do the same without the cost of a sub-shell.

For dash, that is true, so it is worth doing.  But for bash, the
optimization is not yet performed (that is, redirections on a {} group
still cause bash to fork), for no net win in speed.

$ strace -f -e trace=fork bash -c '(nosuch) 2>/dev/null'
Process 11562 attached
Process 11561 suspended
Process 11561 resumed
Process 11562 detached
--- {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=11562, si_status=127,
si_utime=0, si_stime=0} (Child exited) ---
$ strace -f -e trace=fork bash -c '{ nosuch;} 2>/dev/null'
Process 11567 attached
Process 11566 suspended
Process 11566 resumed
Process 11567 detached
--- {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=11567, si_status=127,
si_utime=0, si_stime=0} (Child exited) ---
$ strace -f -e trace=fork dash -c '(nosuch) 2>/dev/null'
Process 11581 attached
Process 11581 detached
--- {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=11581, si_status=127,
si_utime=0, si_stime=0} (Child exited) ---
$ strace -f -e trace=fork dash -c '{ nosuch;} 2>/dev/null'

Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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