[trace] Prevent a child process from writing to the same file

After opening a specific file or fd for ourselves, reset the
CAIRO_TRACE_FD to point to an invalid fd in order to prevent any child
processes (who inherit our environment) from attempting to trace cairo
calls. If we allow them to continue, then the two traces will intermix
and be unreplayable.
This commit is contained in:
Chris Wilson 2009-06-19 14:41:39 +01:00
parent 18edea36ba
commit 84e587bbfa

View file

@ -709,12 +709,17 @@ _init_logfile (void)
filename = getenv ("CAIRO_TRACE_FD");
if (filename != NULL) {
int fd = atoi (filename);
if (fd == -1)
return false;
logfile = fdopen (fd, "w");
if (logfile == NULL) {
fprintf (stderr, "Failed to open trace file descriptor '%s': %s\n",
filename, strerror (errno));
return false;
}
setenv ("CAIRO_TRACE_FD", "-1", 1);
goto done;
}
@ -734,6 +739,8 @@ _init_logfile (void)
filename, name, getpid());
filename = buf;
setenv ("CAIRO_TRACE_FD", "-1", 1);
}
logfile = fopen (filename, "wb");