mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 09:58:12 +02:00
[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:
parent
18edea36ba
commit
84e587bbfa
1 changed files with 7 additions and 0 deletions
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue