.\" -*- 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 Septiembre 2017" GNU "Manual del Programador de Linux" .SH NOMBRE popen, pclose \- flujo desde o hacia un proceso .SH SINOPSIS .nf \fB#include \fP .PP \fBFILE *popen(const char *\fP\fIorden\fP\fB, const char *\fP\fItipo\fP\fB);\fP .PP \fBint pclose(FILE *\fP\fIflujo\fP\fB);\fP .fi .PP .RS -4 Requisitos de Macros de Prueba de Características para glibc (véase \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 DESCRIPCIÓN La función \fBpopen\fP() inicia un proceso creando una tubería, llamando a \fBfork\fP(2) para crear el proceso y ejecutando el intérprete de órdenes (shell). Puesto que una tubería es unidireccional por definición, el argumento \fItipo\fP sólo puede especificar lectura o escritura, pero no ambos; el flujo resultante es respctivamente de lectura o escritura exclusiva. .PP El argumento \fIorden\fP es un puntero a una cadena terminada en cero que contiene una línea de orden del shell. Esta orden se pasa a \fI/bin/sh\fP precedida de la opción \fB\-c\fP; si se necesita interpretar la línea, esto lo hace el 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 The return value from \fBpopen\fP() is a normal standard I/O stream in all respects save that it must be closed with \fBpclose\fP() rather than \fBfclose\fP(3). Writing to such a stream writes to the standard input of the command; the command's standard output is the same as that of the process that called \fBpopen\fP(), unless this is altered by the command itself. Conversely, reading from the stream reads the command's standard output, and the command's standard input is the same as that of the process that called \fBpopen\fP(). .PP Note that output \fBpopen\fP() streams are block buffered by default. .PP La función \fBpclose\fP() espera que el proceso asociado termine, y devuelve el estado de salida de la orden como el devuelto por \fBwait4\fP(2). .SH "VALOR DEVUELTO" \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 ERRORES La función \fBpopen\fP() no asigna un valor a \fIerrno\fP si falla la reserva de memoria. Si las funciones subyacentes \fBfork\fP(2) o \fBpipe\fP(2) fallan, a \fIerrno\fP se le asigna un valor apropiado. Si el argumento \fItipo\fP es incorrecto y se detecta esta condición, a \fIerrno\fP se le asigna el valor \fBEINVAL\fP. .PP Si \fBpclose\fP() no puede obtener el estado del hijo, se asigna a \fIerrno\fP el valor \fBECHILD\fP. .SH ATRIBUTOS Para obtener una explicación de los términos usados en esta sección, véase \fBattributes\fP(7). .TS allbox; lbw17 lb lb l l l. Interfaz Atributo Valor T{ \fBpopen\fP(), \fBpclose\fP() T} Seguridad del hilo Multi\-hilo seguro .TE .sp 1 .SH "CONFORME A" POSIX.1\-2001, POSIX.1\-2008. .PP The \(aqe\(aq value for \fItype\fP is a Linux extension. .SH NOTAS \fBNote\fP: carefully read Caveats in \fBsystem\fP(3). .SH ERRORES Puesto que la entrada estándar de una orden abierta para lectura comparte su puntero de posición con el proceso que llamó a \fBpopen\fP(), si el proceso original ha hecho una lectura tamponada, la posición en la entrada de la orden puede no ser la esperada. De forma similar, la salida de una orden abierta para escritura puede resultar mezclada con la del proceso original. Esto último puede evitarse llamando a \fBfflush\fP(3) antes de a \fBpopen\fP(). .PP .\" .SH HISTORY .\" A .\" .BR popen () .\" and a .\" .BR pclose () .\" function appeared in Version 7 AT&T UNIX. Un fallo al ejecutar el shell es indistinguible de un fallo del shell al ejecutar la orden, o una salida inmediata de la orden. La única pista es un estado de salida 127. .SH "VÉASE TAMBIÉN" \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 COLOFÓN Esta página es parte de la versión 5.10 del proyecto Linux \fIman\-pages\fP. Puede encontrar una descripción del proyecto, información sobre cómo informar errores y la última versión de esta página en \%https://www.kernel.org/doc/man\-pages/. .PP .SH TRADUCCIÓN La traducción al español de esta página del manual fue creada por Gerardo Aburruzaga García , Juan Piernas y Marcos Fouces . .PP Esta traducción es documentación libre; lea la .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 .UE o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD. .PP Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a .MT debian-l10n-spanish@lists.debian.org .ME .