kern_fork.c (108338) | kern_fork.c (108520) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1989, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_fork.c 8.6 (Berkeley) 4/8/94 | 1/* 2 * Copyright (c) 1982, 1986, 1989, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_fork.c 8.6 (Berkeley) 4/8/94 |
39 * $FreeBSD: head/sys/kern/kern_fork.c 108338 2002-12-28 01:23:07Z julian $ | 39 * $FreeBSD: head/sys/kern/kern_fork.c 108520 2003-01-01 01:01:14Z alfred $ |
40 */ 41 42#include "opt_ktrace.h" 43#include "opt_mac.h" 44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/sysproto.h> --- 205 unchanged lines hidden (view full) --- 253 if ((flags & RFPROC) == 0) { 254 vm_forkproc(td, NULL, NULL, flags); 255 256 /* 257 * Close all file descriptors. 258 */ 259 if (flags & RFCFDG) { 260 struct filedesc *fdtmp; | 40 */ 41 42#include "opt_ktrace.h" 43#include "opt_mac.h" 44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/sysproto.h> --- 205 unchanged lines hidden (view full) --- 253 if ((flags & RFPROC) == 0) { 254 vm_forkproc(td, NULL, NULL, flags); 255 256 /* 257 * Close all file descriptors. 258 */ 259 if (flags & RFCFDG) { 260 struct filedesc *fdtmp; |
261 fdtmp = fdinit(td); /* XXXKSE */ 262 fdfree(td); /* XXXKSE */ | 261 fdtmp = fdinit(td->td_proc->p_fd); 262 fdfree(td); |
263 p1->p_fd = fdtmp; 264 } 265 266 /* 267 * Unshare file descriptors (from parent.) 268 */ 269 if (flags & RFFDG) { 270 FILEDESC_LOCK(p1->p_fd); --- 169 unchanged lines hidden (view full) --- 440 } 441 442 /* 443 * Copy filedesc. 444 * XXX: This is busted. fd*() need to not take proc 445 * arguments or something. 446 */ 447 if (flags & RFCFDG) | 263 p1->p_fd = fdtmp; 264 } 265 266 /* 267 * Unshare file descriptors (from parent.) 268 */ 269 if (flags & RFFDG) { 270 FILEDESC_LOCK(p1->p_fd); --- 169 unchanged lines hidden (view full) --- 440 } 441 442 /* 443 * Copy filedesc. 444 * XXX: This is busted. fd*() need to not take proc 445 * arguments or something. 446 */ 447 if (flags & RFCFDG) |
448 fd = fdinit(td); | 448 fd = fdinit(td->td_proc->p_fd); |
449 else if (flags & RFFDG) { 450 FILEDESC_LOCK(p1->p_fd); 451 fd = fdcopy(td); 452 FILEDESC_UNLOCK(p1->p_fd); 453 } else | 449 else if (flags & RFFDG) { 450 FILEDESC_LOCK(p1->p_fd); 451 fd = fdcopy(td); 452 FILEDESC_UNLOCK(p1->p_fd); 453 } else |
454 fd = fdshare(p1); | 454 fd = fdshare(p1->p_fd); |
455 456 /* 457 * Make a proc table entry for the new process. 458 * Start by zeroing the section of proc that is zero-initialized, 459 * then copy the section that is copied directly from the parent. 460 */ 461 td2 = FIRST_THREAD_IN_PROC(p2); 462 kg2 = FIRST_KSEGRP_IN_PROC(p2); --- 450 unchanged lines hidden --- | 455 456 /* 457 * Make a proc table entry for the new process. 458 * Start by zeroing the section of proc that is zero-initialized, 459 * then copy the section that is copied directly from the parent. 460 */ 461 td2 = FIRST_THREAD_IN_PROC(p2); 462 kg2 = FIRST_KSEGRP_IN_PROC(p2); --- 450 unchanged lines hidden --- |