.\" -*- 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 "23. Juli 2015" Linux Linux\-Programmierhandbuch .SH BEZEICHNUNG getpid, getppid \- gibt die Prozessidentifikation zurück .SH ÜBERSICHT \fB#include \fP .br \fB#include \fP .sp \fBpid_t getpid(void);\fP .br \fBpid_t getppid(void);\fP .SH BESCHREIBUNG \fBgetpid\fP() gibt die Prozess\-ID des aufrufenden Prozesses zurück. (Dies wird oft von Routinen benutzt, die einen eindeutigen Namen einer temporären Datei erzeugen.) \fBgetppid\fP() gibt die Prozess\-ID des Elternprozesses des aufrufenden Prozesses zurück. .SH FEHLER Diese Funktionen sind immer erfolgreich. .SH "KONFORM ZU" POSIX.1\-2001, POSIX.1\-2008, 4.3BSD, SVr4. .SH ANMERKUNGEN .\" Falls sich der Elternprozess des aufrufenden Prozesses in einem anderen PID\-Namensraum befindet (siehe \fBpid_namespaces\fP(7)), gibt \fBgetppid\fP() 0 zurück. .SS "Unterschiede C\-Bibliothek/Kernel" .\" 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); .\"} Seit Version 2.3.4 von Glibc speichert die Glibc\-Wrapper\-Funktion für \fBgetpid\fP() PIDs temporär, um zusätzliche Systemaufrufe zu vermeiden, wenn ein Prozess \fBgetpid\fP() mehrmals aufruft. Normalerweise ist dieses Zwischenspeichern nicht sichtbar, aber das korrekte Funktionieren beruht auf der Unterstützung in den Wrapper\-Funktionen für \fBfork\fP(2), \fBvfork\fP(2) und \fBclone\fP(2): Wenn eine Anwendung die Glibc\-Wrapper für diese Systemaufrufe durch Benutzung von \fBsyscall\fP(2) umgeht, dann wird ein Aufruf von \fBgetpid\fP() im Kindprozess den falschen Wert zurückliefern (um es zu präzisieren: Er wird die PID des Elternprozesses zurückgeben). Die Handbuchseite von \fBclone\fP(2) diskutiert einen Fall, bei dem \fBgetpid\fP() den falschen Wert sogar dann zurückgibt, wenn \fBclone\fP(2) über die Glibc\-Wrapper\-Funktion aufgerufen wird. .SH "SIEHE AUCH" \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), \fBpid_namespaces\fP(7) .SH KOLOPHON Diese Seite ist Teil der Veröffentlichung 4.09 des Projekts Linux\-\fIman\-pages\fP. Eine Beschreibung des Projekts, Informationen, wie Fehler gemeldet werden können sowie die aktuelle Version dieser Seite finden sich unter \%https://www.kernel.org/doc/man\-pages/. .SH ÜBERSETZUNG Die deutsche Übersetzung dieser Handbuchseite wurde von Stefan Janke , Chris Leick und Mario Blättermann erstellt. Diese Übersetzung ist Freie Dokumentation; lesen Sie die GNU General Public License Version 3 oder neuer bezüglich der Copyright-Bedingungen. Es wird KEINE HAFTUNG übernommen. Wenn Sie Fehler in der Übersetzung dieser Handbuchseite finden, schicken Sie bitte eine E-Mail an .