Function: redirect-debugging-output
redirect-debugging-output is an interactive function defined in
print.c.
Signature
(redirect-debugging-output FILE &optional APPEND)
Documentation
Redirect debugging output (stderr stream) to file FILE.
If FILE is nil, reset target to the initial stderr stream. Optional arg APPEND non-nil (interactively, with prefix arg) means append to existing target file.
Probably introduced at or before Emacs version 22.1.
Key Bindings
Source Code
// Defined in /usr/src/emacs/src/print.c
{
/* If equal to STDERR_FILENO, stderr has not been duplicated and is OK as-is.
Otherwise, this is a close-on-exec duplicate of the original stderr. */
static int stderr_dup = STDERR_FILENO;
int fd = stderr_dup;
if (! NILP (file))
{
file = Fexpand_file_name (file, Qnil);
if (stderr_dup == STDERR_FILENO)
{
int n = fcntl (STDERR_FILENO, F_DUPFD_CLOEXEC, STDERR_FILENO + 1);
if (n < 0)
report_file_error ("dup", file);
stderr_dup = n;
}
fd = emacs_open (SSDATA (ENCODE_FILE (file)),
(O_WRONLY | O_CREAT
| (! NILP (append) ? O_APPEND : O_TRUNC)),
0666);
if (fd < 0)
report_file_error ("Cannot open debugging output stream", file);
}
fflush (stderr);
if (dup2 (fd, STDERR_FILENO) < 0)
report_file_error ("dup2", file);
if (fd != stderr_dup)
emacs_close (fd);
return Qnil;
}