.\" -*- coding: UTF-8 -*-
.\" Copyright (c) 1999 Andries Brouwer (aeb@cwi.nl), 1 Nov 1999
.\" and Copyright 2006, 2012, 2017 Michael Kerrisk <mtk.manpages@gmail.com>
.\"
.\" %%%LICENSE_START(VERBATIM)
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\" %%%LICENSE_END
.\"
.\" 1999-11-10: Merged text taken from the page contributed by
.\" Reed H. Petty (rhp@draper.net)
.\"
.\"*******************************************************************
.\"
.\" This file was generated with po4a. Translate the source file.
.\"
.\"*******************************************************************
.TH VFORK 2 "15 septembre 2017" Linux "Manuel du programmeur Linux"
.SH NOM
vfork \- Créer un processus fils et bloquer le père
.SH SYNOPSIS
\fB#include <sys/types.h>\fP
.br
\fB#include <unistd.h>\fP
.PP
\fBpid_t vfork(void);\fP
.PP
.RS -4
Exigences de macros de test de fonctionnalités pour la glibc (consulter
\fBfeature_test_macros\fP(7))\ :
.RE
.PP
\fBvfork\fP()\ :
.ad l
.RS 4
.PD 0
.TP  4
Depuis la glibc 2.12 :
.nf
(_XOPEN_SOURCE\ >=\ 500) && ! (_POSIX_C_SOURCE\ >=\ 200809L)
    || /* Since glibc 2.19: */ _DEFAULT_SOURCE
    || /* Glibc versions <= 2.19: */ _BSD_SOURCE
.fi
.TP  4
Avant la glibc 2.12\ :
.\"     || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
.PD
.RE
.ad b
.SH DESCRIPTION
.SS "Description des normes"
(D'après POSIX.1). La routine \fBvfork\fP() a le même effet que \fBfork\fP(2),
sauf que le comportement est indéfini si le processus créé par \fBvfork\fP()
effectue l'une des actions suivantes avant d'appeler avec succès \fB_exit\fP(2)
ou une routine de la famille \fBexec\fP(3)\ : modification d'une donnée autre
que la variable de type \fIpid_t\fP stockant le retour de \fBvfork\fP(), revenir
de la fonction dans laquelle \fBvfork\fP() a été invoqué, appel d'une autre
fonction.
.SS "Description de l'implémentation Linux"
\fBvfork\fP(), tout comme \fBfork\fP(2), crée un processus fils à partir du
processus appelant. Pour plus de détails sur les valeurs renvoyées et les
erreurs possibles, consultez \fBfork\fP(2).
.PP
\fBvfork\fP() est conçu comme un cas particulier de \fBclone\fP(2). Il sert à
créer un nouveau processus sans effectuer de copie de la table des pages
mémoire du processus père. Ceci peut être utile dans des applications
nécessitant une grande rapidité d'exécution, si le fils doit invoquer
immédiatement un appel \fBexecve\fP(2).
.PP
\fBvfork\fP()  differs from \fBfork\fP(2)  in that the calling thread is suspended
until the child terminates (either normally, by calling \fB_exit\fP(2), or
abnormally, after delivery of a fatal signal), or it makes a call to
\fBexecve\fP(2).  Until that point, the child shares all memory with its
parent, including the stack.  The child must not return from the current
function or call \fBexit\fP(3)  (which would have the effect of calling exit
handlers established by the parent process and flushing the parent's
\fBstdio\fP(3)  buffers), but may call \fB_exit\fP(2).
.PP
Comme avec \fBfork\fP(2), le processus fils créé par \fBvfork\fP()  hérite des
copies de plusieurs attributs du processus appelant (par exemple les
descripteurs de fichiers, les dispositions des signaux et le répertoire de
travail actuel)\ ; l'appel \fBvfork\fP()  diffère seulement par le traitement
de l'espace d'adressage virtuel, comme décrit ci\-dessus.
.PP
Les signaux pour le processus père sont délivrés après que le fils libère la
mémoire du père (c'est\-à\-dire après que le fils se termine ou qu'il appelle
\fBexecve\fP(2)).
.SS "Description historique"
Sous Linux, \fBfork\fP(2) est implémenté en utilisant un mécanisme de copie en
écriture, ainsi ses seuls coûts sont le temps et la mémoire nécessaire pour
dupliquer la table des pages mémoire du processus père, et créer une
structure de tâche pour le fils. Toutefois, jadis \fBfork\fP(2) nécessitait
malheureusement une copie complète de l'espace d'adresse du père, souvent
inutile car un appel \fBexec\fP(3) est souvent réalisé immédiatement par le
fils. Pour améliorer les performances, BSD a introduit un appel système
\fBvfork\fP() qui ne copie pas l'espace d'adressage du père, mais emprunte au
parent son espace d'adressage et son fil de contrôle jusqu'à un appel à
\fBexecve\fP(2) ou exit. Le processus père était suspendu tant que le fils
utilisait les ressources. L'utilisation de \fBvfork\fP() était loin d'être
facile, car pour éviter de modifier les données du processus père, il
fallait être capable de déterminer quelles variables se trouvaient dans des
registres du processeur.
.SH CONFORMITÉ
BSD\ 4.3, POSIX.1\-2001 (mais la déclare obsolète). POSIX.1\-2008 supprime la
spécification de \fBvfork\fP().
.PP
.\" In AIXv3.1 vfork is equivalent to fork.
Les exigences que les standards apportent sur \fBvfork\fP() sont plus relâchées
que celles sur \fBfork\fP(2), ainsi il est possible d'avoir une implémentation
conforme où les deux appels sont synonymes. En particulier, un programmeur
ne doit pas s'appuyer sur le fait que le père reste bloqué jusqu'à ce que le
fils se termine ou appelle \fBexecve\fP(2), ni sur le comportement par rapport
à la mémoire partagée.
.SH NOTES
Certaines personnes considèrent la sémantique de \fBvfork\fP() comme une verrue
architecturale, et la page de manuel de BSD\ 4.2 indique que «\ cet appel
système sera supprimé quand des mécanismes de partage appropriés seront
implémentés. Il ne faut pas essayer de tirer profit du partage mémoire
induit par \fBvfork\fP(), car dans ce cas il sera rendu synonyme de \fBfork\fP(2)\ ». Cependant, même si le matériel de gestion mémoire matériel a diminué la
différence de performances entre \fBfork\fP(2) et \fBvfork\fP(), il existe
diverses raisons pour lesquelles Linux et d'autres systèmes ont conservé
\fBvfork\fP()\ :
.IP * 3
Certaines applications de haute performance ont besoin du petit gain apporté
par \fBvfork\fP().
.IP *
.\" http://stackoverflow.com/questions/4259629/what-is-the-difference-between-fork-and-vfork
.\" http://developers.sun.com/solaris/articles/subprocess/subprocess.html
.\" http://mailman.uclinux.org/pipermail/uclinux-dev/2009-April/000684.html
.\"
\fBvfork\fP() peut être implémenté sur des systèmes sans unité de gestion
mémoire (MMU, pour «\ memory\-management unit\ »), mais \fBfork\fP(2) ne peut
pas être implémenté sur de tels systèmes (POSIX.1\-2008 a supprimé \fBvfork\fP()
de la norme\ ; la raison invoquée par POSIX pour la fonction
\fBposix_spawn\fP(3) note que cette fonction, qui fournit une fonctionnalité
équivalente à \fBfork\fP(2)+\fBexec\fP(3), est conçue pour être implémentable sur
des systèmes sans MMU).
.IP *
.\"
On systems where memory is constrained, \fBvfork\fP()  avoids the need to
temporarily commit memory (see the description of
\fI/proc/sys/vm/overcommit_memory\fP in \fBproc\fP(5))  in order to execute a new
program.  (This can be especially beneficial where a large parent process
wishes to execute a small helper program in a child process.)  By contrast,
using \fBfork\fP(2)  in this scenario requires either committing an amount of
memory equal to the size of the parent process (if strict overcommitting is
in force)  or overcommitting memory with the risk that a process is
terminated by the out\-of\-memory (OOM) killer.
.SS "Mises en garde"
The child process should take care not to modify the memory in unintended
ways, since such changes will be seen by the parent process once the child
terminates or executes another program.  In this regard, signal handlers can
be especially problematic: if a signal handler that is invoked in the child
of \fBvfork\fP()  changes memory, those changes may result in an inconsistent
process state from the perspective of the parent process (e.g., memory
changes would be visible in the parent, but changes to the state of open
file descriptors would not be visible).
.PP
.\"
When \fBvfork\fP()  is called in a multithreaded process, only the calling
thread is suspended until the child terminates or executes a new program.
This means that the child is sharing an address space with other running
code.  This can be dangerous if another thread in the parent process changes
credentials (using \fBsetuid\fP(2)  or similar), since there are now two
processes with different privilege levels running in the same address
space.  As an example of the dangers, suppose that a multithreaded program
running as root creates a child using \fBvfork\fP().  After the \fBvfork\fP(), a
thread in the parent process drops the process to an unprivileged user in
order to run some untrusted code (e.g., perhaps via plug\-in opened with
\fBdlopen\fP(3)).  In this case, attacks are possible where the parent process
uses \fBmmap\fP(2)  to map in code that will be executed by the privileged
child process.
.SS "Notes pour Linux"
Les gestionnaires enregistrés avec \fBpthread_atfork\fP(3) ne sont pas appelés
lorsqu'un programme multithreadé utilisant la bibliothèque de threads NPTL
appelle \fBvfork\fP(). En revanche ces gestionnaires sont appelés si le
programme utilise la bibliothèque LinuxThreads. (Consultez \fBpthreads\fP(7)
pour une description des bibliothèques de threads pour Linux.)
.PP
Un appel à \fBvfork\fP()  est équivalent à appeler \fBclone\fP(2)  avec \fIflags\fP
valant\ :
.PP
     CLONE_VM | CLONE_VFORK | SIGCHLD
.SS Historique
.\" In the release notes for 4.2BSD Sam Leffler wrote: `vfork: Is still
.\" present, but definitely on its way out'.
The \fBvfork\fP()  system call appeared in 3.0BSD.  In 4.4BSD it was made
synonymous to \fBfork\fP(2)  but NetBSD introduced it again; see
.UR http://www.netbsd.org\:/Documentation\:/kernel\:/vfork.html
.UE .
In
Linux, it has been equivalent to \fBfork\fP(2)  until 2.2.0\-pre6 or so.  Since
2.2.0\-pre9 (on i386, somewhat later on other architectures) it is an
independent system call.  Support was added in glibc 2.0.112.
.SH BOGUES
.\"
.\" As far as I can tell, the following is not true in 2.6.19:
.\" Currently (Linux 2.3.25),
.\" .BR strace (1)
.\" cannot follow
.\" .BR vfork ()
.\" and requires a kernel patch.
Les détails de la gestion des signaux sont compliqués, et varient suivant
les systèmes. La page de manuel BSD indique\ : «\ Pour éviter une possible
situation d'interblocage, les processus qui sont des fils au milieu d'un
\fBvfork\fP() ne reçoivent jamais le signal \fBSIGTTOU\fP ou \fBSIGTTIN\fP\ ; des
sorties et des \fIioctl\fP sont autorisés, mais des tentatives de lecture
donneront une indication de fin de fichier.\ »
.SH "VOIR AUSSI"
\fBclone\fP(2), \fBexecve\fP(2), \fB_exit\fP(2), \fBfork\fP(2), \fBunshare\fP(2),
\fBwait\fP(2)
.SH COLOPHON
Cette page fait partie de la publication\ 5.10 du projet \fIman\-pages\fP
Linux. Une description du projet et des instructions pour signaler des
anomalies et la dernière version de cette page peuvent être trouvées à
l'adresse \%https://www.kernel.org/doc/man\-pages/.

.SH TRADUCTION
La traduction française de cette page de manuel a été créée par
Christophe Blaess <https://www.blaess.fr/christophe/>,
Stéphan Rafin <stephan.rafin@laposte.net>,
Thierry Vignaud <tvignaud@mandriva.com>,
François Micaux,
Alain Portal <aportal@univ-montp2.fr>,
Jean-Philippe Guérard <fevrier@tigreraye.org>,
Jean-Luc Coulon (f5ibh) <jean-luc.coulon@wanadoo.fr>,
Julien Cristau <jcristau@debian.org>,
Thomas Huriaux <thomas.huriaux@gmail.com>,
Nicolas François <nicolas.francois@centraliens.net>,
Florentin Duneau <fduneau@gmail.com>,
Simon Paillard <simon.paillard@resel.enst-bretagne.fr>,
Denis Barbier <barbier@debian.org>
et
David Prévot <david@tilapin.org>
.

Cette traduction est une documentation libre ; veuillez vous reporter à la
.UR https://www.gnu.org/licenses/gpl-3.0.html
GNU General Public License version 3
.UE
concernant les conditions de copie et 
de distribution. Il n'y a aucune RESPONSABILITÉ LÉGALE.

Si vous découvrez un bogue dans la traduction de cette page de manuel, 
veuillez envoyer un message à
.MT
debian-l10n-french@lists.debian.org
.ME .