[MINC-users] Tempdir handling by some MINC tools

Alex Zijdenbos zijdenbos at gmail.com
Thu Jun 25 16:26:02 EDT 2020


Hello all,

I recently figured out why I am now and again running into some annoying
mincdiff failures, where mincdiff does not report "Images are identical"
even though they actually are. This comes back to the way mincheader
creates and uses a temporary directory, here:

https://github.com/BIC-MNI/minc-tools/blob/master/progs/mincheader/mincheader#L68-L76


There are two problems with this bit of code:

   1. it will generate a tempdir solely based on the pid. The pid is of
   course unique at that moment, but the generated directory may not be - for
   example, in case previous invocations with a (past) identical pid were not
   cleaned up. So something like mincdiff (that calls mincheader) might fail,
   solely because of a tempdir name clash
   2. in the case of mincheader, the only use case for this appears to be
   in case of externally compressed .mnc.gz files. I am not sure who still
   uses those (I don't), but this means that working with internally
   compressed MINC2 files, each mincheader call will create a dir in /tmp that
   is subsequently not used for anything.

Similar bits of tempdir/file code exist in mincinfo, mincdiff, and likely
others.

I was wondering if anybody might have fixed this already. In perl this is
easy, using File::Temp that will guarantee unique temporary files - but
these tools are all shell scripts. If somebody has some .sh code lying
around that does this better, perhaps that can be slotted into these tools
pretty easily?

Thanks,

-- A


More information about the MINC-users mailing list