[MINC-users] Tempdir handling by some MINC tools

Alex Zijdenbos zijdenbos at gmail.com
Fri Jun 26 10:16:50 EDT 2020


Thanks, Gabriel - I filed  https://github.com/BIC-MNI/minc-tools/issues/105

On Thu, Jun 25, 2020 at 4:54 PM Gabriel A. Devenyi <
gabriel.devenyi at mcgill.ca> wrote:

> Can you please open an issue listing all the scripts you caught this in and
> I'll look into swapping in some more robust code. Maybe we can do this
> before we push 1.9.18
>
> Thanks!
>
> --------------------------------------------------------
> Asking for technical help? Get help fast:
> https://www.chiark.greenend.org.uk/~sgtatham/bugs.html
> http://www.catb.org/~esr/faqs/smart-questions.html#beprecise
> https://en.wikipedia.org/wiki/XY_problem
> https://stackoverflow.com/help/minimal-reproducible-example
>
>
> --
> Gabriel A. Devenyi Ph.D.
> Research Computing Associate
> Computational Brain Anatomy Laboratory
> Cerebral Imaging Center
> Douglas Mental Health University Institute
> Affiliate, Department of Psychiatry
> McGill University
> t: 514.761.6131x4781
> e: gabriel.devenyi at mcgill.ca
>
>
> On Thu, 25 Jun 2020 at 16:46, Gabriel A. Devenyi <
> gabriel.devenyi at mcgill.ca>
> wrote:
>
> > We can fix this up with "mktemp -d" in shell scripts.
> > --------------------------------------------------------
> > Asking for technical help? Get help fast:
> > https://www.chiark.greenend.org.uk/~sgtatham/bugs.html
> > http://www.catb.org/~esr/faqs/smart-questions.html#beprecise
> > https://en.wikipedia.org/wiki/XY_problem
> > https://stackoverflow.com/help/minimal-reproducible-example
> >
> >
> > --
> > Gabriel A. Devenyi Ph.D.
> > Research Computing Associate
> > Computational Brain Anatomy Laboratory
> > Cerebral Imaging Center
> > Douglas Mental Health University Institute
> > Affiliate, Department of Psychiatry
> > McGill University
> > t: 514.761.6131x4781
> > e: gabriel.devenyi at mcgill.ca
> >
> >
> > On Thu, 25 Jun 2020 at 16:26, Alex Zijdenbos <zijdenbos at gmail.com>
> wrote:
> >
> >> 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
> >> _______________________________________________
> >> MINC-users at bic.mni.mcgill.ca
> >> https://mailman.bic.mni.mcgill.ca/mailman/listinfo/minc-users
> >>
> >
> _______________________________________________
> MINC-users at bic.mni.mcgill.ca
> https://mailman.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>
>


More information about the MINC-users mailing list