No. You can duplicate a file POINTER. You can't duplicate a file
STRUCTURE. There is no excuse for it either -- your user program
should never mess with a FILE structure but only have pointers to it.
>
> Glibc doesn't check the contents of the FILE structures, just
> the addresses and since it "knows" the pointer received was not
> one it provided, it generates signal 11 on its own. Is this
> REALLY what is supposed to happen? After all, the function call
> did get a perfectly valid pointer to the required structure.
>
No it didn't. You duplicated the FILE *structure*, which may itself
contain pointers to other structures inside libc.
Your program is totally and utterly broken. SIGSEGV is a perfectly
acceptable and quite reasonable.
-hpa
-- PGP: 2047/2A960705 BA 03 D3 2C 14 A8 A8 BD 1E DF FE 69 EE 35 BD 74 See http://www.zytor.com/~hpa/ for web page and full PGP public key I am Bahá'í -- ask me about it or see http://www.bahai.org/ "To love another person is to see the face of God." -- Les Misérables- 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.tux.org/lkml/