From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18209 invoked by alias); 7 Mar 2004 23:18:43 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 18192 invoked from network); 7 Mar 2004 23:18:42 -0000 Received: from unknown (HELO Cantor.suse.de) (195.135.220.2) by sources.redhat.com with SMTP; 7 Mar 2004 23:18:42 -0000 Received: from hermes.suse.de (Hermes.suse.de [195.135.221.8]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by Cantor.suse.de (Postfix) with ESMTP id 2C2452B0585 for ; Mon, 8 Mar 2004 00:18:42 +0100 (CET) To: libc-hacker@sources.redhat.com Subject: getpid/vfork broken From: Andreas Schwab X-Yow: After THIS, let's go to PHILADELPHIA and have TRIPLETS!! Date: Sun, 07 Mar 2004 23:18:00 -0000 Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-SW-Source: 2004-03/txt/msg00014.txt.bz2 getpid does not return the correct result after vfork: $ cat getpid.c #include #include #include #include #include int main (void) { if (vfork () == 0) { printf ("%d\n", getpid ()); exit (0); } wait (0); if (vfork () == 0) { printf ("%d\n", getpid ()); exit (0); } wait (0); printf ("%d\n", getpid ()); return 0; } $ ./getpid 31302 31302 31302 Note that the number is actually the pid of the first child, not the parent. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."