diff options
author | Paul Smith <psmith@gnu.org> | 2022-08-27 19:03:40 -0400 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2022-08-30 15:39:02 -0400 |
commit | a2ba5ccbda4606dde29503f57caab33a974af5bf (patch) | |
tree | 09ae52b4c14dd5f363aa37e1e5f35387c1c82156 /NEWS | |
parent | 5eff618c8cbfbe1f386e3a55499cd8fe26cd35a1 (diff) | |
download | make-git-a2ba5ccbda4606dde29503f57caab33a974af5bf.tar.gz |
Add get_tmpfd() and allow anonymous temp files
The output sync feature wants a file descriptor not a FILE*. We were
using tmpfile() but this returns FILE* which means we needed to dup()
the descriptor then fclose() the original, which is just unnecessary
overhead for every command we run.
Create a get_tmpfd() method that returns a file descriptor directly
by using mkstemp() if available, else do the best we can.
Also allow anonymous temp files if the filename pointer is NULL.
This causes the file to be unlinked. On Windows this requires a
special open so add an os_anontmp() method to handle this.
* src/makeint.h: Add prototype for get_tmpfd().
* src/misc.c (get_tmpfd): If we have mkstemp() use that, else just
open(2). If we don't want to keep the filename, unlink the file.
(get_tmpfile): Use get_tmpfd() if we have fdopen(), else use fopen().
* src/output.c (output_tmpfd): Call get_tmpfd() with NULL.
* src/os.h (os_anontmp): On Windows make this a function, else fails.
* src/w32/compat/posixcfn.c (tmpfile): Move to w32os.c:os_anontmp().
* src/w32/w32os.c (os_anontmp): Create a temp file that will be deleted
when the process exits, and return a file descriptor to it.
Diffstat (limited to 'NEWS')
0 files changed, 0 insertions, 0 deletions