www.delorie.com/djgpp/doc/libc/libc_653.html   search  
libc.a reference

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

redir_to_child

Syntax

 
#include <debug/redir.h>

int redir_to_child (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 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.

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

 
  errno = 0;
  if (redir_to_child (&child_cmd) == -1)
    {
      redir_to_debugger (&child_cmd);
      error ("Cannot redirect standard handles for program: %s.",
             strerror (errno));
    }


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004