Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Jul 2000 06:10:01 +0100
From:      "Nigel Roles" <ngr@9fs.org>
To:        <freebsd-hackers@freebsd.org>
Subject:   rfork(RFMEM) behaviour
Message-ID:  <DAENIBHPCGABMPCKEANMIEPMCCAA.ngr@9fs.org>

next in thread | raw e-mail | index | archive | help
I am getting strange behaviour with rfork(RFMEM) on a ~2 week old
kernel. The following code illustrates it. For all the world, the
stack appears to be shareable after the fork. This is clearly wrong,
since pid was at some point different in parent and child for them
to take the right case.

I'm sure this is down to my stupidity. I'd be grateful for any
feedback.

Also, I understand that rfork(RFMEM) was not supported in 3.3 under
SMP. My reading of the kernel source suggests that there is no longer
such a limitation. At which version did this change?

Thanks,

Nigel Roles


--------------------------------------- 


#include <stdio.h>
#include <unistd.h>

int child_has_run;

int
main(int argc, char **argv)
{
	int pid;
	int value = 3;
	pid = rfork(RFPROC | RFMEM);
	switch (pid) {
	case 0:
		pid = -1;
		printf("child has run\n");
		fflush(0);
		child_has_run = 1;
		exit(0);
	case -1:
		printf("rfork failed\n");
		exit(1);
	default:
		while (!child_has_run)
			;
		printf("parent pid = %d\n", pid);
	}
	exit(1);
}



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?DAENIBHPCGABMPCKEANMIEPMCCAA.ngr>