.\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992 .\" .\" 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. .\" .\" Modified by Michael Haardt (michael@moria.de) .\" Modified Sat Jul 24 13:22:07 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified 21 Aug 1994 by Michael Chastain (mec@shell.portal.com): .\" Referenced 'clone(2)'. .\" Modified 1995-06-10, 1996-04-18, 1999-11-01, 2000-12-24 .\" by Andries Brouwer (aeb@cwi.nl) .\" .\" Translated 25 December Miguel A. Sepulveda (miguel@typhoon.harvard.edu) .\" Modified 1 Jul 1996 Miguel A. Sepulveda (angel@vivaldi.princeton.edu) .\" Translation revised on Tue Apr 28 16:34:06 CEST 1998 by Gerardo .\" Aburruzaga García .\" Modified 1 Nov 1999 by Andries Brouwer (aeb@cwi.nl) .\" Translation revised Sat Jan 8 2000 by Juan Piernas .\" .TH FORK 2 "1 julio 1996" "Linux 1.2.9" "Manual del Programador de Linux" .SH NOMBRE fork \- crean un proceso hijo .SH SINOPSIS .B #include .br .B #include .sp .B pid_t fork(void); .SH DESCRIPCIÓN .B fork crea un proceso hijo que difiere de su proceso padre sólo en su PID y PPID, y en el hecho de que el uso de recursos esté asignado a 0. Los candados de fichero (file locks) y las señales pendientes no se heredan. .PP En linux, .B fork está implementado usando páginas de copia-en-escritura (copy-on-write), así que la única penalización en que incurre fork es en el tiempo y memoria requeridos para duplicar las tablas de páginas del padre, y para crear una única estructura de tarea (task structure) para el hijo. .SH "VALOR DEVUELTO" En caso de éxito, se devuelve el PID del proceso hijo en el hilo de ejecución de su padre, y se devuelve un 0 en el hilo de ejecución del hijo. En caso de fallo, se devolverá un \-1 en el contexto del padre, no se creará ningún proceso hijo, y se pondrá en .I errno un valor apropiado. .SH ERRORES .TP .B EAGAIN .B fork no puede reservar sufficiente memoria para copiar las tablas de páginas del padre y alojar una estructura de tarea para el hijo. .TP .B ENOMEM .B fork no pudo obtener las necesarias estructuras del núcleo porque la cantidad de memoria era escasa. .SH "CONFORME A" La llamada al sistema .B fork es conforme con SVr4, SVID, POSIX, X/OPEN y BSD 4.3. .SH "VÉASE TAMBIÉN" .BR clone (2), .BR execve (2), .BR wait (2)