NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/49017: vfork does not suspend all threads
>Number: 49017
>Category: kern
>Synopsis: vfork does not suspend all threads
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Jul 18 17:10:00 +0000 2014
>Originator: Christos Zoulas
>Release: NetBSD 6.99.47
>Organization:
You've been vforked!
>Environment:
System: NetBSD quasar.astron.com 6.99.47 NetBSD 6.99.47 (QUASAR) #2: Fri Jul 18
08:23:06 EDT 2014
christos%quasar.astron.com@localhost:/usr/src/sys/arch/amd64/compile/QUASAR
amd64
Architecture: x86_64
Machine: amd64
>Description:
vfork is supposed to suspend the parent while the child is preparing for
exec. The parent is resumed after the child exec's or exits. This is done
so that the memory image shared between the parent and the child is not
changed by the parent while it is preparing to exec.
>How-To-Repeat:
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <err.h>
#define NTHREAD 2
void *
worker(void *arg) {
size_t *i = arg;
for (size_t j = 0;; j++) {
printf("[%d] %zu %zu\n", getpid(), *i, j);
sleep(1);
}
}
int
main(int argc, char *argv[])
{
pthread_t t[NTHREAD];
for (size_t i = 0; i < NTHREAD; i++)
pthread_create(&t[i], NULL, worker, &i);
switch (vfork()) {
case -1:
err(1, "vfork");
case 0:
default:
sleep(100000);
break;
}
return 0;
}
>Fix:
Home |
Main Index |
Thread Index |
Old Index