Go to the first, previous, next, last section, table of contents.
#include <debug/redir.h> int redir_to_child (cmdline_t *cmd);
For the rationale and general description of the debugger redirection issue, see section redir_debug_init.
This function redirects all 3 standard streams so that they point to the
files/devices where the child (a.k.a. debuggee) process connected
them. All three standard handles point to the console device by
default, but this could be changed, either because the command line for
the child requested redirection, like in `prog > foo', or because
the child program itself redirected one of its standard handles
e.g. with a call to dup2
.
redir_to_child
uses information stored in the cmdline_t
variable pointed to by the cmd argument to redirect the standard
streams as appropriate for the debuggee, while saving the original
debugger's handles to be restored by redir_to_debugger
.
The function returns zero in case of success, -1 in case of failure. Failure usually means the process has run out of available file handles.
not ANSI, not POSIX
errno = 0; if (redir_to_child (&child_cmd) == -1) { redir_to_debugger (&child_cmd); error ("Cannot redirect standard handles for program: %s.", strerror (errno)); }
Go to the first, previous, next, last section, table of contents.