Messages in this thread | | | Date | Wed, 26 Aug 1998 13:23:21 -0400 (EDT) | From | "Richard B. Johnson" <> | Subject | Re: Out of ptys |
| |
Alan, This shows the problem I reported to the glibc folks about a year go. Note that both functions, good() and bad(), are identical except for the fds that I close.
#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
| |