From owner-freebsd-hackers Sun Jul 16 22:11:18 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net [194.217.242.92]) by hub.freebsd.org (Postfix) with ESMTP id 4141837BA5C for ; Sun, 16 Jul 2000 22:11:15 -0700 (PDT) (envelope-from ngr@9fs.org) Received: from cotswold.demon.co.uk ([194.222.75.186] helo=blue) by anchor-post-34.mail.demon.net with smtp (Exim 2.12 #1) id 13E3BS-0005sX-0Y for freebsd-hackers@freebsd.org; Mon, 17 Jul 2000 06:11:14 +0100 From: "Nigel Roles" To: Subject: rfork(RFMEM) behaviour Date: Mon, 17 Jul 2000 06:10:01 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 #include 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