.\" -*- 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 września 2017 r." GNU "Podręcznik programisty Linuksa" .SH NAZWA popen, pclose \- pipe stream to or from a process .SH SKŁADNIA .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 .in -4n Wymagane ustawienia makr biblioteki glibc (patrz \fBfeature_test_macros\fP(7)): .ad l .in .PP \fBpopen\fP(), \fBpclose\fP(): .RS 4 _POSIX_C_SOURCE\ >=\ 2 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE .RE .ad b .SH OPIS Funkcja \fBpopen\fP() otwiera proces, tworząc łącze, rozwidlając się przez fork() i wywołując powłokę. Ponieważ łącze jest z definicji jednokierunkowe, argument \fItype\fP może określać tylko odczyt albo tylko zapis, nie oba naraz. Otrzymany w wyniku tego strumień będzie tylko do odczytu albo tylko do zapisu. .PP Argument \fIcommand\fP jest wskaźnikiem do zakończonego znakiem NUL łańcucha, zawierającego wiersz poleceń powłoki. Polecenie to jest przekazywane do \fI/bin/sh\fP przy użyciu opcji \fB\-c\fP; wszelka interpretacja jest dokonywana przez powłokę. .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 Należy zauważyć, że strumienie wyjściowe powstałe z \fBpopen\fP() są domyślnie w pełni buforowane. .PP Funkcja \fBpclose\fP() oczekuje na zakończenie stowarzyszonego procesu i zwraca jego kod zakończenia, podobnie jak to czyni \fBwait4\fP(2). .SH "WARTOŚĆ ZWRACANA" \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 BŁĘDY Funkcja \fBpopen\fP() nie ustawia \fIerrno\fP, jeżeli nie uda się przydzielić pamięci. Jeżeli nie powiodą sięwywoływane przez nią \fBfork\fP(2) lub \fBpipe\fP(2), to \fIerrno\fP będzie odpowiednio ustawione. Jeżeli argument \fItype\fP będzie nieprawidłowy i zostanie to wykryte, to \fIerrno\fP zostanie ustawione na \fBEINVAL\fP. .PP Jeżeli nie będzie możliwe otrzymanie kodu zakończenia procesu potomnego przez \fBpclose\fP(), to \fIerrno\fP zostanie ustawione na \fBECHILD\fP. .SH ATRYBUTY Informacje o pojęciach używanych w tym rozdziale można znaleźć w podręczniku \fBattributes\fP(7). .TS allbox; lbw17 lb lb l l l. Interfejs Atrybut Wartość T{ \fBpopen\fP(), \fBpclose\fP() T} Bezpieczeństwo wątkowe MT\-Safe .TE .sp 1 .SH "ZGODNE Z" POSIX.1\-2001, POSIX.1\-2008. .PP The \(aqe\(aq value for \fItype\fP is a Linux extension. .SH UWAGI \fBNote\fP: carefully read Caveats in \fBsystem\fP(3). .SH BŁĘDY Ponieważ offset standardowego wejścia polecenia otwartego dla odczytu jest taki sam dla tego polecenia i dla procesu, który wywołał \fBpopen\fP(), więc jeśli oryginalny proces wykona buforowany odczyt, to pozycja na wejściu polecenia może być inna niż oczekiwano. Podobnie, wyjście polecenia otwartego dla zapisu może zostać wymieszane z wyjściem procesu oryginalnego. Temu ostatniemu można zapobiec, wołając przed \fBpopen\fP() funkcję \fBfflush\fP(3). .PP .\" .SH HISTORY .\" A .\" .BR popen () .\" and a .\" .BR pclose () .\" function appeared in Version 7 AT&T UNIX. Błąd w wywołaniu powłoki jest nieodróżnialny od błędu powłoki przy wywoływaniu polecenia, czy od natychmiastowego zakończenia polecenia. Jedynym śladem jest kod zakończenia równy 127. .SH "ZOBACZ TAKŻE" \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 "O STRONIE" Angielska wersja tej strony pochodzi z wydania 5.04 projektu Linux \fIman\-pages\fP. Opis projektu, informacje dotyczące zgłaszania błędów oraz najnowszą wersję oryginału można znaleźć pod adresem \%https://www.kernel.org/doc/man\-pages/. .SH TŁUMACZENIE Autorami polskiego tłumaczenia niniejszej strony podręcznika są: Przemek Borys , Jarosław Beczek i Andrzej Krzysztofowicz . Niniejsze tłumaczenie jest wolną dokumentacją. Bliższe informacje o warunkach licencji można uzyskać zapoznając się z .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License w wersji 3 .UE lub nowszej. Nie przyjmuje się ŻADNEJ ODPOWIEDZIALNOŚCI. Błędy w tłumaczeniu strony podręcznika prosimy zgłaszać na adres .MT manpages-pl-list@lists.sourceforge.net .ME .