> > I read your first comment on this. Your demo programs don't
> > relate at all to the problem.
>
> You keep claiming things don't work. Im just going to sit here proving
> they do. If you play this game for long enough we might even find a real
> library bug
>
Well here it is. You chose what the "correct" behavior should be. I'll
except anything. However, both STDERR_FILENO and STDOUT_FILENO had
better function the same or there is a library problem.
#include <stdio.h>
#include <unistd.h>
void bad()
{
int i;
close(STDOUT_FILENO);
i = fprintf(stdout, "Hello world!\n");
if(i > 0)
fprintf(stderr, "Bad! %d bytes copied to (closed) stdout...\n", i);
else
fprintf(stderr, "Good! (%d)\n", i);
}
void good()
{
int i;
close(STDERR_FILENO);
i = fprintf(stderr, "Hello world!\n");
if(i > 0)
fprintf(stdout, "Bad! %d bytes copied to (closed) stderr...\n", i);
else
fprintf(stdout, "Good! (%d)\n", i);
}
int main(int argc, char *argv[])
{
int ch;
if(argc > 1)
{
ch = (int) *argv[1];
ch &=95;
switch(ch)
{
case 'G':
good();
break;
case 'B':
bad();
break;
default:
fprintf(stderr, "Huh (%c) ??\n", ch);
break;
}
}
else
fprintf(stderr, "Usage: %s [Good/Bad]\n", argv[0]);
return 0;
}
Cheers,
Dick Johnson
***** FILE SYSTEM WAS MODIFIED *****
Penguin : Linux version 2.1.115 on an i586 machine (66.15 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html