fork.c (158d9ebd19280582da172626ad3edda1a626dace) | fork.c (92476d7fc0326a409ab1d3864a04093a6be9aca7) |
---|---|
1/* 2 * linux/kernel/fork.c 3 * 4 * Copyright (C) 1991, 1992 Linus Torvalds 5 */ 6 7/* 8 * 'fork.c' contains the help-routines for the 'fork' system call --- 1301 unchanged lines hidden (view full) --- 1310 unsigned long stack_start, 1311 struct pt_regs *regs, 1312 unsigned long stack_size, 1313 int __user *parent_tidptr, 1314 int __user *child_tidptr) 1315{ 1316 struct task_struct *p; 1317 int trace = 0; | 1/* 2 * linux/kernel/fork.c 3 * 4 * Copyright (C) 1991, 1992 Linus Torvalds 5 */ 6 7/* 8 * 'fork.c' contains the help-routines for the 'fork' system call --- 1301 unchanged lines hidden (view full) --- 1310 unsigned long stack_start, 1311 struct pt_regs *regs, 1312 unsigned long stack_size, 1313 int __user *parent_tidptr, 1314 int __user *child_tidptr) 1315{ 1316 struct task_struct *p; 1317 int trace = 0; |
1318 long pid = alloc_pidmap(); | 1318 struct pid *pid = alloc_pid(); 1319 long nr; |
1319 | 1320 |
1320 if (pid < 0) | 1321 if (!pid) |
1321 return -EAGAIN; | 1322 return -EAGAIN; |
1323 nr = pid->nr; |
|
1322 if (unlikely(current->ptrace)) { 1323 trace = fork_traceflag (clone_flags); 1324 if (trace) 1325 clone_flags |= CLONE_PTRACE; 1326 } 1327 | 1324 if (unlikely(current->ptrace)) { 1325 trace = fork_traceflag (clone_flags); 1326 if (trace) 1327 clone_flags |= CLONE_PTRACE; 1328 } 1329 |
1328 p = copy_process(clone_flags, stack_start, regs, stack_size, parent_tidptr, child_tidptr, pid); | 1330 p = copy_process(clone_flags, stack_start, regs, stack_size, parent_tidptr, child_tidptr, nr); |
1329 /* 1330 * Do this prior waking up the new thread - the thread pointer 1331 * might get invalid after that point, if the thread exits quickly. 1332 */ 1333 if (!IS_ERR(p)) { 1334 struct completion vfork; 1335 1336 if (clone_flags & CLONE_VFORK) { --- 10 unchanged lines hidden (view full) --- 1347 } 1348 1349 if (!(clone_flags & CLONE_STOPPED)) 1350 wake_up_new_task(p, clone_flags); 1351 else 1352 p->state = TASK_STOPPED; 1353 1354 if (unlikely (trace)) { | 1331 /* 1332 * Do this prior waking up the new thread - the thread pointer 1333 * might get invalid after that point, if the thread exits quickly. 1334 */ 1335 if (!IS_ERR(p)) { 1336 struct completion vfork; 1337 1338 if (clone_flags & CLONE_VFORK) { --- 10 unchanged lines hidden (view full) --- 1349 } 1350 1351 if (!(clone_flags & CLONE_STOPPED)) 1352 wake_up_new_task(p, clone_flags); 1353 else 1354 p->state = TASK_STOPPED; 1355 1356 if (unlikely (trace)) { |
1355 current->ptrace_message = pid; | 1357 current->ptrace_message = nr; |
1356 ptrace_notify ((trace << 8) | SIGTRAP); 1357 } 1358 1359 if (clone_flags & CLONE_VFORK) { 1360 wait_for_completion(&vfork); 1361 if (unlikely (current->ptrace & PT_TRACE_VFORK_DONE)) 1362 ptrace_notify ((PTRACE_EVENT_VFORK_DONE << 8) | SIGTRAP); 1363 } 1364 } else { | 1358 ptrace_notify ((trace << 8) | SIGTRAP); 1359 } 1360 1361 if (clone_flags & CLONE_VFORK) { 1362 wait_for_completion(&vfork); 1363 if (unlikely (current->ptrace & PT_TRACE_VFORK_DONE)) 1364 ptrace_notify ((PTRACE_EVENT_VFORK_DONE << 8) | SIGTRAP); 1365 } 1366 } else { |
1365 free_pidmap(pid); 1366 pid = PTR_ERR(p); | 1367 free_pid(pid); 1368 nr = PTR_ERR(p); |
1367 } | 1369 } |
1368 return pid; | 1370 return nr; |
1369} 1370 1371#ifndef ARCH_MIN_MMSTRUCT_ALIGN 1372#define ARCH_MIN_MMSTRUCT_ALIGN 0 1373#endif 1374 1375static void sighand_ctor(void *data, kmem_cache_t *cachep, unsigned long flags) 1376{ --- 279 unchanged lines hidden --- | 1371} 1372 1373#ifndef ARCH_MIN_MMSTRUCT_ALIGN 1374#define ARCH_MIN_MMSTRUCT_ALIGN 0 1375#endif 1376 1377static void sighand_ctor(void *data, kmem_cache_t *cachep, unsigned long flags) 1378{ --- 279 unchanged lines hidden --- |