.\" -*- coding: UTF-8 -*- '\" t .\" Copyright 1991 The Regents of the University of California. .\" All rights reserved. .\" .\" SPDX-License-Identifier: BSD-4-Clause-UC .\" .\" @(#)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 "20 ​​Julio 2023" "Páginas de manual de Linux 6.05.01" .SH NOMBRE popen, pclose \- flujo desde o hacia un proceso .SH BIBLIOTECA Biblioteca Estándar C (\fIlibc\fP, \fI\-lc\fP) .SH SINOPSIS .nf \fB#include \fP .PP \fBFILE *popen(const char *\fP\fIorden\fP\fB, const char *\fP\fItipo\fP\fB);\fP \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)): .RE .PP \fBpopen\fP(), \fBpclose\fP(): .nf _POSIX_C_SOURCE >= 2 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE .fi .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 \[aq]r\[aq] for reading or the letter \[aq]w\[aq] for writing. Since glibc 2.9, this argument can additionally include the letter \[aq]e\[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 On failure, both functions set \fIerrno\fP to indicate the error. .SH ERRORES The \fBpopen\fP() function does not set \fIerrno\fP if memory allocation fails. If the underlying \fBfork\fP(2) or \fBpipe\fP(2) fails, \fIerrno\fP is set to indicate the error. If the \fItype\fP argument is invalid, and this condition is detected, \fIerrno\fP is set to \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; lbx lb lb l l l. Interfaz Atributo Valor T{ .na .nh \fBpopen\fP(), \fBpclose\fP() T} Seguridad del hilo Multi\-hilo seguro .TE .sp 1 .SH VERSIONES The \[aq]e\[aq] value for \fItype\fP is a Linux extension. .SH ESTÁNDARES POSIX.1\-2008. .SH HISTORIAL POSIX.1\-2001. .SH CAVEATS 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) .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 .