delorie.com/djgpp/doc/libc/libc_654.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

redir_to_debugger

Syntax

 
#include <debug/redir.h>

int redir_to_debugger (cmdline_t *cmd);

Description

For the rationale and general description of the debugger redirection issue, see redir_debug_init.

This function redirects all 3 standard streams so that they point to the files/devices where the debugger 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_debugger uses information stored in the cmdline_t variable pointed to by the cmd argument to redirect the standard streams as appropriate for the debugger, while saving the original debuggee's handles to be restored by redir_to_child.

Return Value

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.

Portability

ANSI/ISO C No
POSIX No

Example

 
 /* Restore debugger's standard handles.  */
 errno = 0;
 if (redir_to_debugger (&child_cmd) == -1)
   error ("Cannot redirect standard handles for debugger: %s.",
          strerror (errno));


  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004