.\" -*- coding: UTF-8 -*- .\" Copyright 1991 The Regents of the University of California. .\" All rights reserved. .\" .\" %%%LICENSE_START(BSD_4_CLAUSE_UCB) .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" %%%LICENSE_END .\" .\" @(#)popen.3 6.4 (Berkeley) 4/30/91 .\" .\" Converted for Linux, Mon Nov 29 14:45:38 1993, faith@cs.unc.edu .\" Modified Sat May 18 20:37:44 1996 by Martin Schulze (joey@linux.de) .\" Modified 7 May 1998 by Joseph S. Myers (jsm28@cam.ac.uk) .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH POPEN 3 "15 septembre 2017" GNU "Manuel du programmeur Linux" .SH NOM popen, pclose \- Tuyau entrant ou sortant pour un processus .SH SYNOPSIS .nf \fB#include \fP .PP \fBFILE *popen(const char *\fP\fIcommand\fP\fB, const char *\fP\fItype\fP\fB);\fP .PP \fBint pclose(FILE *\fP\fIstream\fP\fB);\fP .fi .PP .RS -4 Exigences de macros de test de fonctionnalités pour la glibc (consulter \fBfeature_test_macros\fP(7))\ : .ad l .RE .PP \fBpopen\fP(), \fBpclose\fP()\ : .RS 4 _POSIX_C_SOURCE\ >=\ 2 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE .RE .ad b .SH DESCRIPTION La fonction \fBpopen\fP() engendre un processus en créant un tube (pipe), exécutant un \fBfork\fP(), et en invoquant le shell. Comme un tube est unidirectionnel par définition, l'argument \fItype\fP doit indiquer seulement une lecture ou une écriture, et non pas les deux. Le flux correspondant sera ouvert en lecture seule ou écriture seule. .PP The \fIcommand\fP argument is a pointer to a null\-terminated string containing a shell command line. This command is passed to \fI/bin/sh\fP using the \fB\-c\fP flag; interpretation, if any, is performed by the shell. .PP The \fItype\fP argument is a pointer to a null\-terminated string which must contain either the letter \(aqr\(aq for reading or the letter \(aqw\(aq for writing. Since glibc 2.9, this argument can additionally include the letter \(aqe\(aq, which causes the close\-on\-exec flag (\fBFD_CLOEXEC\fP) to be set on the underlying file descriptor; see the description of the \fBO_CLOEXEC\fP flag in \fBopen\fP(2) for reasons why this may be useful. .PP La valeur renvoyée par \fBpopen\fP() est un flux d'entrée\-sortie normal, à la seule différence qu'il doit être fermé en appelant \fBpclose\fP() à la place de \fBfclose\fP(3). L'écriture dans le flux correspond à écrire sur l'entrée standard de la commande. Le flux de sortie standard de la commande est le même que celui du processus appelant \fBpopen\fP(), à moins que la commande le modifie. Symétriquement, la lecture depuis un flux correspond à lire la sortie standard de la commande, et dans ce cas l'entrée standard de la commande est la même que celle du processus appelant \fBpopen\fP(). .PP Note that output \fBpopen\fP() streams are block buffered by default. .PP La fonction \fBpclose\fP() attend que le processus correspondant se termine, et renvoie alors l'état de sortie de la commande, comme en utilisant \fBwait4\fP(2). .SH "VALEUR RENVOYÉE" \fBpopen\fP(): on success, returns a pointer to an open stream that can be used to read or write to the pipe; if the \fBfork\fP(2) or \fBpipe\fP(2) calls fail, or if the function cannot allocate memory, NULL is returned. .PP .\" These conditions actually give undefined results, so I commented .\" them out. .\" .I stream .\" is not associated with a "popen()ed" command, if .\".I stream .\" already "pclose()d", or if \fBpclose\fP(): on success, returns the exit status of the command; if \fBwait4\fP(2) returns an error, or some other error is detected, \-1 is returned. .PP Both functions set \fIerrno\fP to an appropriate value in the case of an error. .SH ERREURS La fonction \fBpopen\fP ne remplit pas \fIerrno\fP si une allocation mémoire échoue. Si les appels \fBfork\fP(2) ou \fBpipe\fP(2) sous\-jacents échouent, \fIerrno\fP est correctement rempli. Si l'argument \fItype\fP est invalide, et si cette condition est détectée, \fIerrno\fP contient \fBEINVAL\fP. .PP Si \fBpclose\fP() n'arrive pas à obtenir l'état du fils, \fIerrno\fP contient \fBECHILD\fP. .SH ATTRIBUTS Pour une explication des termes utilisés dans cette section, consulter \fBattributes\fP(7). .TS allbox; lbw17 lb lb l l l. Interface Attribut Valeur T{ \fBpopen\fP(), \fBpclose\fP() T} Sécurité des threads MT\-Safe .TE .sp 1 .SH CONFORMITÉ POSIX.1\-2001, POSIX.1\-2008. .PP La valeur «\ e\ » pour \fItype\fP est une extension Linux. .SH NOTES \fBNote\fP: carefully read Caveats in \fBsystem\fP(3). .SH BOGUES Comme l'entrée standard d'une commande ouverte en lecture partage son pointeur de position dans le flux avec le processus appelant \fBpopen\fP(), si le processus original a effectué des lectures en tampon, la position du flux d'entrée de la commande peut être différente de celle attendue. Symétriquement, la sortie d'une commande ouverte en écriture peut s'emmêler avec celle du processus original. Le second problème peut être évité en appelant \fBfflush\fP(3) avant \fBpopen\fP(). .PP .\" .SH HISTORY .\" A .\" .BR popen () .\" and a .\" .BR pclose () .\" function appeared in Version 7 AT&T UNIX. Il n'est pas possible de distinguer un échec d'exécution du shell lui\-même, d'un échec d'exécution d'une commande par le shell, ni même d'une sortie immédiate de la commande. Le seul indice est un code de retour de 127. .SH "VOIR AUSSI" \fBsh\fP(1), \fBfork\fP(2), \fBpipe\fP(2), \fBwait4\fP(2), \fBfclose\fP(3), \fBfflush\fP(3), \fBfopen\fP(3), \fBstdio\fP(3), \fBsystem\fP(3) .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 , Stéphan Rafin , Thierry Vignaud , François Micaux, Alain Portal , Jean-Philippe Guérard , Jean-Luc Coulon (f5ibh) , Julien Cristau , Thomas Huriaux , Nicolas François , Florentin Duneau , Simon Paillard , Denis Barbier , David Prévot et Frédéric Hantrais . 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 .