[LTP] [PATCH v3] runltp: add -R option for randomize test order

Cyril Hrubis chrubis@suse.cz
Mon Sep 26 10:25:01 CEST 2016


Hi!
> Hm, it works, even works for large file (>pagesize). I thought it maybe make
> mistake if read and rewrite same file at same time when I sent this patch.
> Now I just read the code of sort.c, it'll read the file into buffer and temp
> file at first, then close the fopen(r) file and go to fopen(w) the file:
> 
>           if (buf.eof && !nfiles && !ntemps && !buf.left)
>             {
>               xfclose (fp, file);
>               tfp = xfopen (output_file, "w");
> 	      ...
> 	      ...
> 
> So it looks safe to read and write the same file together ... But I don't know
> if it worth changing this patch (the old way looks safer:). Can maintainers
> choose a favorite way?

The POSIX specification for sort explicitly states:

-o  output
    Specify the name of an output file to be used instead of the
    standard output. This file can be the same as one of the input
    files.

So I would say that using the same filename for input and output is
pretty much safe.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list