.\" -*- coding: UTF-8 -*-
.\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
.\"
.\" %%%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
.\"
.\"*******************************************************************
.\"
.\" This file was generated with po4a. Translate the source file.
.\"
.\"*******************************************************************
.TH GETPID 2 "1 listopada 2020 r." Linux "Podręcznik programisty Linuksa"
.SH NAZWA
getpid, getppid \- pobranie identyfikatora procesu
.SH SKŁADNIA
\fB#include <sys/types.h>\fP
.br
\fB#include <unistd.h>\fP
.PP
\fBpid_t getpid(void);\fP
.br
\fBpid_t getppid(void);\fP
.SH OPIS
\fBgetpid\fP() zwraca identyfikator procesu (PID) wywołującego. (Jest to często
wykorzystywane przez funkcje generujące unikatowe nazwy plików
tymczasowych).
.PP
\fBgetppid\fP()  returns the process ID of the parent of the calling process.
This will be either the ID of the process that created this process using
\fBfork\fP(), or, if that process has already terminated, the ID of the process
to which this process has been reparented (either \fBinit\fP(1)  or a
"subreaper" process defined via the \fBprctl\fP(2)  \fBPR_SET_CHILD_SUBREAPER\fP
operation).
.SH BŁĘDY
Funkcje te zawsze kończą się pomyślnie.
.SH "ZGODNE Z"
POSIX.1\-2001, POSIX.1\-2008, 4.3BSD, SVr4.
.SH UWAGI
Jeśli rodzic wywołującego jest w innej przestrzeni nazw PID
(zob. \fBpid_namespaces\fP(7)), \fBgetppid\fP() zwraca 0.
.PP
.\"
From a kernel perspective, the PID (which is shared by all of the threads in
a multithreaded process)  is sometimes also known as the thread group ID
(TGID).  This contrasts with the kernel thread ID (TID), which is unique for
each thread.  For further details, see \fBgettid\fP(2)  and the discussion of
the \fBCLONE_THREAD\fP flag in \fBclone\fP(2).
.SS "Różnice biblioteki C/jądra"
.\" The following program demonstrates this "feature":
.\"
.\" #define _GNU_SOURCE
.\" #include <sys/syscall.h>
.\" #include <sys/wait.h>
.\" #include <stdint.h>
.\" #include <stdio.h>
.\" #include <stdlib.h>
.\" #include <unistd.h>
.\"
.\" int
.\" main(int argc, char *argv[])
.\" {
.\"    /* The following statement fills the getpid() cache */
.\"
.\"    printf("parent PID = %ld\n", (intmax_t) getpid());
.\"
.\"    if (syscall(SYS_fork) == 0) {
.\"        if (getpid() != syscall(SYS_getpid))
.\"            printf("child getpid() mismatch: getpid()=%jd; "
.\"                    "syscall(SYS_getpid)=%ld\n",
.\"                    (intmax_t) getpid(), (long) syscall(SYS_getpid));
.\"        exit(EXIT_SUCCESS);
.\"    }
.\"    wait(NULL);
.\"}
From glibc version 2.3.4 up to and including version 2.24, the glibc wrapper
function for \fBgetpid\fP()  cached PIDs, with the goal of avoiding additional
system calls when a process calls \fBgetpid\fP()  repeatedly.  Normally this
caching was invisible, but its correct operation relied on support in the
wrapper functions for \fBfork\fP(2), \fBvfork\fP(2), and \fBclone\fP(2): if an
application bypassed the glibc wrappers for these system calls by using
\fBsyscall\fP(2), then a call to \fBgetpid\fP()  in the child would return the
wrong value (to be precise: it would return the PID of the parent process).
In addition, there were cases where \fBgetpid\fP()  could return the wrong
value even when invoking \fBclone\fP(2)  via the glibc wrapper function.  (For
a discussion of one such case, see BUGS in \fBclone\fP(2).)  Furthermore, the
complexity of the caching code had been the source of a few bugs within
glibc over the years.
.PP
.\" commit c579f48edba88380635ab98cb612030e3ed8691e
.\" https://sourceware.org/glibc/wiki/Release/2.25#pid_cache_removal
.\" FIXME .
.\" Review progress of https://bugzilla.redhat.com/show_bug.cgi?id=1469757
Because of the aforementioned problems, since glibc version 2.25, the PID
cache is removed: calls to \fBgetpid\fP()  always invoke the actual system
call, rather than returning a cached value.
.PP
On Alpha, instead of a pair of \fBgetpid\fP()  and \fBgetppid\fP()  system calls,
a single \fBgetxpid\fP()  system call is provided, which returns a pair of PID
and parent PID.  The glibc \fBgetpid\fP()  and \fBgetppid\fP()  wrapper functions
transparently deal with this.  See \fBsyscall\fP(2)  for details regarding
register mapping.
.SH "ZOBACZ TAKŻE"
\fBclone\fP(2), \fBfork\fP(2), \fBgettid\fP(2), \fBkill\fP(2), \fBexec\fP(3),
\fBmkstemp\fP(3), \fBtempnam\fP(3), \fBtmpfile\fP(3), \fBtmpnam\fP(3),
\fBcredentials\fP(7), \fBpid_namespaces\fP(7)
.SH "O STRONIE"
Angielska wersja tej strony pochodzi z wydania 5.10 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/.
.PP
.SH TŁUMACZENIE
Autorami polskiego tłumaczenia niniejszej strony podręcznika są:
Przemek Borys <pborys@dione.ids.pl>,
Robert Luberda <robert@debian.org>
i
Michał Kułach <michal.kulach@gmail.com>
.
.PP
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.
.PP
Błędy w tłumaczeniu strony podręcznika prosimy zgłaszać na adres listy
dyskusyjnej
.MT manpages-pl-list@lists.sourceforge.net
.ME .
