.\" -*- 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 Enero 2023" "Páginas de manual de Linux 6.03" .SH NOMBRE getpid, getppid \- obtiene el identificador de proceso .SH BIBLIOTECA Biblioteca Estándar C (\fIlibc\fP, \fI\-lc\fP) .SH SINOPSIS .nf \fB#include \fP .PP \fBpid_t getpid(void);\fP \fBpid_t getppid(void);\fP .fi .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 ESTÁNDARES 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 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 "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) .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 .