gabriel rosenkoetter on Sun, 12 May 2002 17:30:13 +0200


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

Re: [PLUG] can i fork a process in the bash shell?


On Sun, May 12, 2002 at 12:31:18PM +0200, Jeff Abrahamson wrote:
> >     tmp=/tmp/foo.$$.`date +%Y%m%d%H%M%s`
> >     rm -rf $dir $tmp &
> >     do_stuff
> >     while [ -r $tmp ]; do sleep 1; done
> >     do_more_stuff
> Sorry, the careful reader no doubt realized that I forgot to point out
> that you have to touch $tmp before rm'ing it.

Um... and make sure it doesn't exist first (dying, rather than
executing, if it does), since running that script as root gives
any user on the system a free way to destroy your system.

Use mktemp(1), if you really *must* create files.

Also, a sleep 1 is a busy wait that will chew the hell out of your
processor. Maybe not what you want.

-- 
gabriel rosenkoetter
gr@eclipsed.net

Attachment: pgp3gxLDtTRyY.pgp
Description: PGP signature