.\" -*- 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 Noviembre 2020" Linux "Manual del Programador de Linux" .SH NOMBRE getpid, getppid \- obtiene el identificador de proceso .SH SINOPSIS \fB#include \fP .br \fB#include \fP .PP \fBpid_t getpid(void);\fP .br \fBpid_t getppid(void);\fP .SH DESCRIPCIÓN \fBgetpid\fP devuelve el identificador de proceso (PID) del proceso actual. Esto suele ser usado por rutinas que generan nombres únicos de archivos temporales. .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 ERRORES Estas funciones siempre terminan sin error. .SH "CONFORME A" POSIX.1\-2001, POSIX.1\-2008, 4.3BSD, SVr4. .SH NOTAS Si el antecesor del invocante está en un espacio de nombres diferente al PID (consulte \fBpid_namespaces\fP(7)), \fBgetppid\fP() tendrá un estado de salida de 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 "Diferencias núcleo / biblioteca C" .\" The following program demonstrates this "feature": .\" .\" #define _GNU_SOURCE .\" #include .\" #include .\" #include .\" #include .\" #include .\" #include .\" .\" 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 "VÉASE TAMBIÉN" \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 COLOFÓN Esta página es parte de la versión 5.10 del proyecto Linux \fIman\-pages\fP. Puede encontrar una descripción del proyecto, información sobre cómo informar errores y la última versión de esta página en \%https://www.kernel.org/doc/man\-pages/. .PP .SH TRADUCCIÓN La traducción al español de esta página del manual fue creada por Nicolás Lichtmaier , Juan Piernas y Marcos Fouces . .PP Esta traducción es documentación libre; lea la .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 .UE o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD. .PP Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a .MT debian-l10n-spanish@lists.debian.org .ME .