hiho@ll
excuse for the generalized subject, but i was to uncreative to post it in another way
well my "problem":
i have this code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(){
close(2);
printf("TEST");
}
which gets executed this way:
Code:
g++ -o descr.o descr.test.c
./descr.o 2>err.out 1>&2
what does this do?
in the prog itself i only close stderr (2) and write the String TEST to stdout (1)
the commandline redirects
stderr to a file err.out
and
stdout to stderr
what i'm asking myself now is
why does this work?
if i do a
cat err.out
i get
TEST
this means that printf("TEST"); has been written to err.out through stderr, which i closed at the begining of the prog!?
thx@ll