.\" -*- coding: UTF-8 -*-
.\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.\"*******************************************************************
.\"
.\" This file was generated with po4a. Translate the source file.
.\"
.\"*******************************************************************
.TH getpid 2 "22 stycznia 2023 r." "Linux man\-pages 6.03" 
.SH NAZWA
getpid, getppid \- pobranie identyfikatora procesu
.SH BIBLIOTEKA
Standardowa biblioteka C (\fIlibc\fP, \fI\-lc\fP)
.SH SKŁADNIA
.nf
\fB#include <unistd.h>\fP
.PP
\fBpid_t getpid(void);\fP
\fBpid_t getppid(void);\fP
.fi
.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 STANDARDY
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 2.3.4 up to and including glibc 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 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)
.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 .
