* doc/make.texi: Document temporary file name prefix

* src/posixos.c (jobserver_setup): Set prefix for FIFO temp file.
Ensure it can't conflict with a "normal" temp file.
* src/w32/w32os.c (os_anontmp): Set prefix for anon temp files.
This commit is contained in:
Paul Smith 2024-03-24 16:23:28 -04:00
parent 242603fa46
commit 3d4f3e0627
3 changed files with 7 additions and 5 deletions

View File

@ -9462,7 +9462,8 @@ regardless of any @code{.WARNINGS} assignments.
In some situations, @code{make} will need to create its own temporary files.
These files must not be disturbed while @code{make} is running, including all
recursively-invoked instances of @code{make}.
recursively-invoked instances of @code{make}. All temporary filenames created
by GNU Make will start with the letters @samp{Gm}.
@cindex @code{MAKE_TMPDIR}
If the environment variable @code{MAKE_TMPDIR} is set then all temporary files

View File

@ -152,13 +152,14 @@ jobserver_setup (int slots, const char *style)
{
/* Unfortunately glibc warns about uses of mktemp even though we aren't
using it in dangerous way here. So avoid this by generating our own
temporary file name. */
# define FNAME_PREFIX "GMfifo"
temporary file name. The template in misc.c uses 6 X's so be sure this
name cannot conflict with that. */
# define FNAME_PREFIX "GmFIFO"
const char *tmpdir = get_tmpdir ();
fifo_name = xmalloc (strlen (tmpdir) + CSTRLEN (FNAME_PREFIX)
+ INTSTR_LENGTH + 2);
sprintf (fifo_name, "%s/" FNAME_PREFIX "%" MK_PRI64_PREFIX "d",
sprintf (fifo_name, "%s/" FNAME_PREFIX "%03" MK_PRI64_PREFIX "d",
tmpdir, (long long)make_pid ());
EINTRLOOP (r, mkfifo (fifo_name, 0600));

View File

@ -129,7 +129,7 @@ os_anontmp ()
static unsigned uniq = 0;
static int second_loop = 0;
const char base[] = "gmake_tmpf";
const char base[] = "GmTMPF";
const unsigned sizemax = sizeof (base) - 1 + 4 + 10 + 10;
unsigned pid = GetCurrentProcessId ();