Opened 12 years ago

Last modified 7 years ago

#1902 new defect

g.tempfile -d: make a directory not a filename

Reported by: hamish Owned by: grass-dev@…
Priority: normal Milestone: 8.0.0
Component: Default Version: svn-trunk
Keywords: g.tempfile, scripting, mktemp Cc:
CPU: All Platform: All

Description

Hi,

in grass7 there is a new g.tempfile -d flag to do a "dry run". It is used in core.py by grass.tempdir() to later make a directory by the returned string name. This has three things against it: 1) it causes a race condition. 2) it diverges from the usage of /bin/mktemp -d, which is used to make a directory. 3) it's a lot more convoluted than just making the tempfile a directory in the first place, which is the only(?) known use of -d for dryrun.

I propose that the -d flag in g.tempfile be changed to match mktemp's usage, i.e. make a directory instead.

It is not present in grass6, so there is not a backwards compatibility problem to change it now. I'd suggest that the -d flag to make a new directory would be useful to backport to grass6 once it is ready.

thanks, Hamish

ps- argh trac is logging out every 5 minutes again

Change History (6)

comment:1 by martinl, 12 years ago

No objections, feel free to implement it.

comment:2 by neteler, 11 years ago

Keywords: mktemp added

(Un)related:

To avoid race conditions on high end systems, the use of PID is not save. For a new G_mktemp() implementation, see also ticket #2153

comment:3 by martinl, 9 years ago

Milestone: 7.0.07.0.5

comment:4 by martinl, 8 years ago

Milestone: 7.0.57.3.0

comment:5 by martinl, 8 years ago

Milestone: 7.3.07.4.0

Milestone renamed

comment:6 by mmetz, 7 years ago

Milestone: 7.4.08.0.0

The behaviour of a flag should not be changed within minor releases, bumping up to GRASS 8.

Note: See TracTickets for help on using tickets.