www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/12/14/04:15:42

To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: How to keep a log for syntax errors and warnings?
From: alane AT wozzle DOT linet DOT org (J. Alan Eldridge)
Date: Sun, 13 Dec 92 11:50:50 EST
Organization: Disorganization

src4src!mcdhup!rutgers!uwstout.edu!NATOURI writes:
> I tried to use the redirection symbol >> to collect the messages.
> However, this method failed becuase >> will only redirect standard input; but
> not stderr. Does anyone know of a method to keep a log of all warning and
> syntax errors?  Thanks.

If you're using NDOS or 4DOS as a command interpreter, you can use the
syntax ">& filename" to redirect both. Otherwise, you can write a small
C program to close stdout and stderr, and re-open them to a file.

// assumes Borland C++ or Zortech C++

#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <process.h>

static void redir(char *pszFile)
{
    FILE    *pfOutput = fopen(pszFile,"w");

    int     fd = fileno(pfOutput);

    close(1); close(2); dup(fd); dup(fd);
}

int main(int ac, char **av)
{
    if (ac < 3) exit(0);

    redir(av[1]);

    spawnvp(P_WAIT, av[2], av+2);
}

If there is a FAQ list for this mailing list, this should be on it.
If nobody else is maintaining such a beast, I will _consider_ trying
to do it. Let me know.

alane AT wozzle DOT linet DOT org (J. Alan Eldridge)
Fido: The University of Walamaloo 1:272/38.473

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019