diff options
-rw-r--r-- | include/linux/pid.h | 6 | ||||
-rw-r--r-- | kernel/pid.c | 21 |
2 files changed, 20 insertions, 7 deletions
diff --git a/include/linux/pid.h b/include/linux/pid.h index c7980810eb09..8d199033c0ca 100644 --- a/include/linux/pid.h +++ b/include/linux/pid.h | |||
@@ -89,9 +89,11 @@ extern struct pid *get_task_pid(struct task_struct *task, enum pid_type type); | |||
89 | * attach_pid() and detach_pid() must be called with the tasklist_lock | 89 | * attach_pid() and detach_pid() must be called with the tasklist_lock |
90 | * write-held. | 90 | * write-held. |
91 | */ | 91 | */ |
92 | extern int attach_pid(struct task_struct *task, enum pid_type type, | 92 | extern void attach_pid(struct task_struct *task, enum pid_type type, |
93 | struct pid *pid); | 93 | struct pid *pid); |
94 | extern void detach_pid(struct task_struct *task, enum pid_type); | 94 | extern void detach_pid(struct task_struct *task, enum pid_type); |
95 | extern void change_pid(struct task_struct *task, enum pid_type, | ||
96 | struct pid *pid); | ||
95 | extern void transfer_pid(struct task_struct *old, struct task_struct *new, | 97 | extern void transfer_pid(struct task_struct *old, struct task_struct *new, |
96 | enum pid_type); | 98 | enum pid_type); |
97 | 99 | ||
diff --git a/kernel/pid.c b/kernel/pid.c index e9a31d362b28..20d59fa2d493 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -317,7 +317,7 @@ EXPORT_SYMBOL_GPL(find_pid); | |||
317 | /* | 317 | /* |
318 | * attach_pid() must be called with the tasklist_lock write-held. | 318 | * attach_pid() must be called with the tasklist_lock write-held. |
319 | */ | 319 | */ |
320 | int attach_pid(struct task_struct *task, enum pid_type type, | 320 | void attach_pid(struct task_struct *task, enum pid_type type, |
321 | struct pid *pid) | 321 | struct pid *pid) |
322 | { | 322 | { |
323 | struct pid_link *link; | 323 | struct pid_link *link; |
@@ -325,11 +325,10 @@ int attach_pid(struct task_struct *task, enum pid_type type, | |||
325 | link = &task->pids[type]; | 325 | link = &task->pids[type]; |
326 | link->pid = pid; | 326 | link->pid = pid; |
327 | hlist_add_head_rcu(&link->node, &pid->tasks[type]); | 327 | hlist_add_head_rcu(&link->node, &pid->tasks[type]); |
328 | |||
329 | return 0; | ||
330 | } | 328 | } |
331 | 329 | ||
332 | void detach_pid(struct task_struct *task, enum pid_type type) | 330 | static void __change_pid(struct task_struct *task, enum pid_type type, |
331 | struct pid *new) | ||
333 | { | 332 | { |
334 | struct pid_link *link; | 333 | struct pid_link *link; |
335 | struct pid *pid; | 334 | struct pid *pid; |
@@ -339,7 +338,7 @@ void detach_pid(struct task_struct *task, enum pid_type type) | |||
339 | pid = link->pid; | 338 | pid = link->pid; |
340 | 339 | ||
341 | hlist_del_rcu(&link->node); | 340 | hlist_del_rcu(&link->node); |
342 | link->pid = NULL; | 341 | link->pid = new; |
343 | 342 | ||
344 | for (tmp = PIDTYPE_MAX; --tmp >= 0; ) | 343 | for (tmp = PIDTYPE_MAX; --tmp >= 0; ) |
345 | if (!hlist_empty(&pid->tasks[tmp])) | 344 | if (!hlist_empty(&pid->tasks[tmp])) |
@@ -348,6 +347,18 @@ void detach_pid(struct task_struct *task, enum pid_type type) | |||
348 | free_pid(pid); | 347 | free_pid(pid); |
349 | } | 348 | } |
350 | 349 | ||
350 | void detach_pid(struct task_struct *task, enum pid_type type) | ||
351 | { | ||
352 | __change_pid(task, type, NULL); | ||
353 | } | ||
354 | |||
355 | void change_pid(struct task_struct *task, enum pid_type type, | ||
356 | struct pid *pid) | ||
357 | { | ||
358 | __change_pid(task, type, pid); | ||
359 | attach_pid(task, type, pid); | ||
360 | } | ||
361 | |||
351 | /* transfer_pid is an optimization of attach_pid(new), detach_pid(old) */ | 362 | /* transfer_pid is an optimization of attach_pid(new), detach_pid(old) */ |
352 | void transfer_pid(struct task_struct *old, struct task_struct *new, | 363 | void transfer_pid(struct task_struct *old, struct task_struct *new, |
353 | enum pid_type type) | 364 | enum pid_type type) |