Re: fork() memory corruption... is this glibc2 or kernel?

MOLNAR Ingo (mingo@valerie.inf.elte.hu)
Sun, 21 Jun 1998 05:59:43 +0200 (MET DST)


On Sat, 20 Jun 1998 tbittih@pal.xgw.fi wrote:

> While coding some network apps I noticed that fork() seemed to corrupt
> memory... so I ripped 95% of the program out and changed some things so
> that the bug hit the "critical" memory area around 10x more frequently...

the subtle issue here is that you are using libc6's fgets(), which uses
mmap(), which is not copied on fork() ... this way you might see the
changes done in a child/parent process.

(also, you check for erroneous fork()s in a broken way, fork returns -1 on
error, not 0.)

-- mingo

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu