public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* getpid/vfork broken
@ 2004-03-07 23:18 Andreas Schwab
  2004-03-07 23:30 ` Ulrich Drepper
  0 siblings, 1 reply; 28+ messages in thread
From: Andreas Schwab @ 2004-03-07 23:18 UTC (permalink / raw)
  To: libc-hacker

getpid does not return the correct result after vfork:

$ cat getpid.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

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."

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2004-03-10 23:10 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-07 23:18 getpid/vfork broken Andreas Schwab
2004-03-07 23:30 ` Ulrich Drepper
2004-03-08  2:22   ` Roland McGrath
2004-03-08  2:28     ` Ulrich Drepper
2004-03-08  2:37       ` Roland McGrath
2004-03-08 13:10         ` Jakub Jelinek
2004-03-09  1:28           ` Roland McGrath
2004-03-09  2:04             ` Ulrich Drepper
2004-03-09  3:50               ` Richard Henderson
2004-03-09  7:48           ` Ulrich Drepper
2004-03-09 13:01             ` Andreas Schwab
2004-03-09 13:59               ` [PATCH] getpid/vfork/raise fix Jakub Jelinek
2004-03-09 16:44                 ` Andreas Schwab
2004-03-09 19:38                   ` Jakub Jelinek
2004-03-10  5:53                 ` Ulrich Drepper
2004-03-10 10:37                 ` Andreas Schwab
2004-03-10 12:24                   ` Jakub Jelinek
2004-03-10 14:33                     ` Andreas Schwab
2004-03-10 15:01                       ` Jakub Jelinek
2004-03-10 15:06                         ` Andreas Schwab
2004-03-10 16:56                       ` David Mosberger
2004-03-10 17:02                         ` Jakub Jelinek
2004-03-10 17:45                           ` David Mosberger
2004-03-10 18:19                             ` Jakub Jelinek
2004-03-10 19:24                               ` David Mosberger
2004-03-10 18:44                   ` Ulrich Drepper
2004-03-10 19:18                     ` [PATCH] IA-64 pt-vfork fix Jakub Jelinek
2004-03-10 23:10                       ` Ulrich Drepper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).