.\" 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. .\" .\"******************************************************************* .\" This file is distributed under the same license as original manpage .\" Copyright of the original manpage: .\" Copyright © 1993 Rickard E. Faith .\" Copyright © of Polish translation: .\" Przemek Borys (PTM) , 1998. .\" Robert Luberda , 2013. .TH GETPID 2 2008\-09\-23 Linux "Podręcznik programisty Linuksa" .SH NAZWA getpid, getppid \- pobranie identyfikatora procesu .SH SKŁADNIA \fB#include \fP .br \fB#include \fP .sp \fBpid_t getpid(void);\fP .br \fBpid_t getppid(void);\fP .SH OPIS \fBgetpid\fP() zwraca identyfikator procesu wywołującego. (Jest to często wykorzystywane przez funkcje generujące unikatowe nazwy plików tymczasowych). \fBgetppid\fP() zwraca identyfikator procesu rodzica procesu wywołującego. .SH BŁĘDY Funkcje te zawsze kończą się pomyślnie. .SH "ZGODNE Z" POSIX.1\-2001, 4.3BSD, SVr4. .SH UWAGI .\" The following program demonstrates this "feature": .\" .\" #define _GNU_SOURCE .\" #include .\" #include .\" #include .\" #include .\" #include .\" .\" int .\" main(int argc, char *argv[]) .\" { .\" /* The following statement fills the getpid() cache */ .\" .\" printf("parent PID = %ld\n", (long) getpid()); .\" .\" if (syscall(SYS_fork) == 0) { .\" if (getpid() != syscall(SYS_getpid)) .\" printf("child getpid() mismatch: getpid()=%ld; " .\" "syscall(SYS_getpid)=%ld\n", .\" (long) getpid(), (long) syscall(SYS_getpid)); .\" exit(EXIT_SUCCESS); .\" } .\" wait(NULL); .\"} Od wersji 2.3.4 biblioteki glibc funkcja opakowująca dla \fBgetpid\fP() cache'uje identyfikatory procesów, aby uniknąć dodatkowych wywołań systemowych, jeśli proces powtarza wywołania \fBgetpid\fP(). Normalnie jest to niewidoczne, ale poprawne działanie tego mechanizmu zależy od wsparcia w funkcjach opakowujących \fBfork\fP(2), \fBvfork\fP(2) i \fBclone\fP(2): jeżeli aplikacja omija funkcje opakowujące biblioteki glibc, używając \fBsyscall\fP(2), to \fBgetpid\fP() w procesie potomnym zwróci niepoprawną wartość (a dokładniej: zwróci identyfikator procesu rodzica). Patrz także \fBclone\fP(2), zawierający opis przypadku, w którym \fBgetpid\fP() może zwrócić niepoprawną wartość, nawet jeżeli \fBclone\fP(2) uruchomiono poprzez funkcję opakowującą biblioteki glibc. .SH "ZOBACZ TAKŻE" \fBclone\fP(2), \fBfork\fP(2), \fBkill\fP(2), \fBexec\fP(3), \fBmkstemp\fP(3), \fBtempnam\fP(3), \fBtmpfile\fP(3), \fBtmpnam\fP(3), \fBcredentials\fP(7) .SH "O STRONIE" Angielska wersja tej strony pochodzi z wydania 3.71 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 \%http://www.kernel.org/doc/man\-pages/. .SH TŁUMACZENIE Autorami polskiego tłumaczenia niniejszej strony podręcznika man są: Przemek Borys (PTM) i Robert Luberda . .PP Polskie tłumaczenie jest częścią projektu manpages-pl; uwagi, pomoc, zgłaszanie błędów na stronie http://sourceforge.net/projects/manpages-pl/. Jest zgodne z wersją \fB 3.71 \fPoryginału.