kern_fork.c (89117) | kern_fork.c (89306) |
---|---|
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 89117 2002-01-09 04:51:21Z silby $ | 39 * $FreeBSD: head/sys/kern/kern_fork.c 89306 2002-01-13 11:58:06Z alfred $ |
40 */ 41 42#include "opt_ktrace.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/sysproto.h> 47#include <sys/filedesc.h> --- 216 unchanged lines hidden (view full) --- 264 p1->p_fd = fdtmp; 265 PROC_UNLOCK(p1); 266 } 267 268 /* 269 * Unshare file descriptors (from parent.) 270 */ 271 if (flags & RFFDG) { | 40 */ 41 42#include "opt_ktrace.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/sysproto.h> 47#include <sys/filedesc.h> --- 216 unchanged lines hidden (view full) --- 264 p1->p_fd = fdtmp; 265 PROC_UNLOCK(p1); 266 } 267 268 /* 269 * Unshare file descriptors (from parent.) 270 */ 271 if (flags & RFFDG) { |
272 FILEDESC_LOCK(p1->p_fd); |
|
272 if (p1->p_fd->fd_refcnt > 1) { 273 struct filedesc *newfd; | 273 if (p1->p_fd->fd_refcnt > 1) { 274 struct filedesc *newfd; |
275 |
|
274 newfd = fdcopy(td); | 276 newfd = fdcopy(td); |
277 FILEDESC_UNLOCK(p1->p_fd); |
|
275 PROC_LOCK(p1); 276 fdfree(td); 277 p1->p_fd = newfd; 278 PROC_UNLOCK(p1); | 278 PROC_LOCK(p1); 279 fdfree(td); 280 p1->p_fd = newfd; 281 PROC_UNLOCK(p1); |
279 } | 282 } else 283 FILEDESC_UNLOCK(p1->p_fd); |
280 } 281 *procp = NULL; 282 return (0); 283 } 284 285 /* 286 * Although process entries are dynamically created, we still keep 287 * a global limit on the maximum number we will create. Don't allow --- 226 unchanged lines hidden (view full) --- 514 p2->p_textvp = p1->p_textvp; 515 PROC_UNLOCK(p1); 516 PROC_UNLOCK(p2); 517 if (p2->p_textvp) 518 VREF(p2->p_textvp); 519 520 if (flags & RFCFDG) 521 fd = fdinit(td); | 284 } 285 *procp = NULL; 286 return (0); 287 } 288 289 /* 290 * Although process entries are dynamically created, we still keep 291 * a global limit on the maximum number we will create. Don't allow --- 226 unchanged lines hidden (view full) --- 518 p2->p_textvp = p1->p_textvp; 519 PROC_UNLOCK(p1); 520 PROC_UNLOCK(p2); 521 if (p2->p_textvp) 522 VREF(p2->p_textvp); 523 524 if (flags & RFCFDG) 525 fd = fdinit(td); |
522 else if (flags & RFFDG) | 526 else if (flags & RFFDG) { 527 FILEDESC_LOCK(p1->p_fd); |
523 fd = fdcopy(td); | 528 fd = fdcopy(td); |
524 else | 529 FILEDESC_UNLOCK(p1->p_fd); 530 } else |
525 fd = fdshare(p1); 526 PROC_LOCK(p2); 527 p2->p_fd = fd; 528 529 /* 530 * If p_limit is still copy-on-write, bump refcnt, 531 * otherwise get a copy that won't be modified. 532 * (If PL_SHAREMOD is clear, the structure is shared --- 288 unchanged lines hidden --- | 531 fd = fdshare(p1); 532 PROC_LOCK(p2); 533 p2->p_fd = fd; 534 535 /* 536 * If p_limit is still copy-on-write, bump refcnt, 537 * otherwise get a copy that won't be modified. 538 * (If PL_SHAREMOD is clear, the structure is shared --- 288 unchanged lines hidden --- |