diff options
| author | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-28 08:29:59 -0400 |
|---|---|---|
| committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-28 08:29:59 -0400 |
| commit | 185a257f2f73bcd89050ad02da5bedbc28fc43fa (patch) | |
| tree | 5e32586114534ed3f2165614cba3d578f5d87307 /fs/exec.c | |
| parent | 3f1a9aaeffd8d1cbc5ab9776c45cbd66af1c9699 (diff) | |
| parent | a77c64c1a641950626181b4857abb701d8f38ccc (diff) | |
Merge branch 'master' into gfs2
Diffstat (limited to 'fs/exec.c')
| -rw-r--r-- | fs/exec.c | 53 |
1 files changed, 25 insertions, 28 deletions
| @@ -595,7 +595,7 @@ static int de_thread(struct task_struct *tsk) | |||
| 595 | if (!newsighand) | 595 | if (!newsighand) |
| 596 | return -ENOMEM; | 596 | return -ENOMEM; |
| 597 | 597 | ||
| 598 | if (thread_group_empty(current)) | 598 | if (thread_group_empty(tsk)) |
| 599 | goto no_thread_group; | 599 | goto no_thread_group; |
| 600 | 600 | ||
| 601 | /* | 601 | /* |
| @@ -620,17 +620,17 @@ static int de_thread(struct task_struct *tsk) | |||
| 620 | * Reparenting needs write_lock on tasklist_lock, | 620 | * Reparenting needs write_lock on tasklist_lock, |
| 621 | * so it is safe to do it under read_lock. | 621 | * so it is safe to do it under read_lock. |
| 622 | */ | 622 | */ |
| 623 | if (unlikely(current->group_leader == child_reaper)) | 623 | if (unlikely(tsk->group_leader == child_reaper)) |
| 624 | child_reaper = current; | 624 | child_reaper = tsk; |
| 625 | 625 | ||
| 626 | zap_other_threads(current); | 626 | zap_other_threads(tsk); |
| 627 | read_unlock(&tasklist_lock); | 627 | read_unlock(&tasklist_lock); |
| 628 | 628 | ||
| 629 | /* | 629 | /* |
| 630 | * Account for the thread group leader hanging around: | 630 | * Account for the thread group leader hanging around: |
| 631 | */ | 631 | */ |
| 632 | count = 1; | 632 | count = 1; |
| 633 | if (!thread_group_leader(current)) { | 633 | if (!thread_group_leader(tsk)) { |
| 634 | count = 2; | 634 | count = 2; |
| 635 | /* | 635 | /* |
| 636 | * The SIGALRM timer survives the exec, but needs to point | 636 | * The SIGALRM timer survives the exec, but needs to point |
| @@ -639,14 +639,14 @@ static int de_thread(struct task_struct *tsk) | |||
| 639 | * synchronize with any firing (by calling del_timer_sync) | 639 | * synchronize with any firing (by calling del_timer_sync) |
| 640 | * before we can safely let the old group leader die. | 640 | * before we can safely let the old group leader die. |
| 641 | */ | 641 | */ |
| 642 | sig->tsk = current; | 642 | sig->tsk = tsk; |
| 643 | spin_unlock_irq(lock); | 643 | spin_unlock_irq(lock); |
| 644 | if (hrtimer_cancel(&sig->real_timer)) | 644 | if (hrtimer_cancel(&sig->real_timer)) |
| 645 | hrtimer_restart(&sig->real_timer); | 645 | hrtimer_restart(&sig->real_timer); |
| 646 | spin_lock_irq(lock); | 646 | spin_lock_irq(lock); |
| 647 | } | 647 | } |
| 648 | while (atomic_read(&sig->count) > count) { | 648 | while (atomic_read(&sig->count) > count) { |
| 649 | sig->group_exit_task = current; | 649 | sig->group_exit_task = tsk; |
| 650 | sig->notify_count = count; | 650 | sig->notify_count = count; |
| 651 | __set_current_state(TASK_UNINTERRUPTIBLE); | 651 | __set_current_state(TASK_UNINTERRUPTIBLE); |
| 652 | spin_unlock_irq(lock); | 652 | spin_unlock_irq(lock); |
| @@ -662,13 +662,13 @@ static int de_thread(struct task_struct *tsk) | |||
| 662 | * do is to wait for the thread group leader to become inactive, | 662 | * do is to wait for the thread group leader to become inactive, |
| 663 | * and to assume its PID: | 663 | * and to assume its PID: |
| 664 | */ | 664 | */ |
| 665 | if (!thread_group_leader(current)) { | 665 | if (!thread_group_leader(tsk)) { |
| 666 | /* | 666 | /* |
| 667 | * Wait for the thread group leader to be a zombie. | 667 | * Wait for the thread group leader to be a zombie. |
| 668 | * It should already be zombie at this point, most | 668 | * It should already be zombie at this point, most |
| 669 | * of the time. | 669 | * of the time. |
| 670 | */ | 670 | */ |
| 671 | leader = current->group_leader; | 671 | leader = tsk->group_leader; |
| 672 | while (leader->exit_state != EXIT_ZOMBIE) | 672 | while (leader->exit_state != EXIT_ZOMBIE) |
| 673 | yield(); | 673 | yield(); |
| 674 | 674 | ||
| @@ -682,12 +682,12 @@ static int de_thread(struct task_struct *tsk) | |||
| 682 | * When we take on its identity by switching to its PID, we | 682 | * When we take on its identity by switching to its PID, we |
| 683 | * also take its birthdate (always earlier than our own). | 683 | * also take its birthdate (always earlier than our own). |
| 684 | */ | 684 | */ |
| 685 | current->start_time = leader->start_time; | 685 | tsk->start_time = leader->start_time; |
| 686 | 686 | ||
| 687 | write_lock_irq(&tasklist_lock); | 687 | write_lock_irq(&tasklist_lock); |
| 688 | 688 | ||
| 689 | BUG_ON(leader->tgid != current->tgid); | 689 | BUG_ON(leader->tgid != tsk->tgid); |
| 690 | BUG_ON(current->pid == current->tgid); | 690 | BUG_ON(tsk->pid == tsk->tgid); |
| 691 | /* | 691 | /* |
| 692 | * An exec() starts a new thread group with the | 692 | * An exec() starts a new thread group with the |
| 693 | * TGID of the previous thread group. Rehash the | 693 | * TGID of the previous thread group. Rehash the |
| @@ -696,24 +696,21 @@ static int de_thread(struct task_struct *tsk) | |||
| 696 | */ | 696 | */ |
| 697 | 697 | ||
| 698 | /* Become a process group leader with the old leader's pid. | 698 | /* Become a process group leader with the old leader's pid. |
| 699 | * Note: The old leader also uses thispid until release_task | 699 | * The old leader becomes a thread of the this thread group. |
| 700 | * Note: The old leader also uses this pid until release_task | ||
| 700 | * is called. Odd but simple and correct. | 701 | * is called. Odd but simple and correct. |
| 701 | */ | 702 | */ |
| 702 | detach_pid(current, PIDTYPE_PID); | 703 | detach_pid(tsk, PIDTYPE_PID); |
| 703 | current->pid = leader->pid; | 704 | tsk->pid = leader->pid; |
| 704 | attach_pid(current, PIDTYPE_PID, current->pid); | 705 | attach_pid(tsk, PIDTYPE_PID, tsk->pid); |
| 705 | attach_pid(current, PIDTYPE_PGID, current->signal->pgrp); | 706 | transfer_pid(leader, tsk, PIDTYPE_PGID); |
| 706 | attach_pid(current, PIDTYPE_SID, current->signal->session); | 707 | transfer_pid(leader, tsk, PIDTYPE_SID); |
| 707 | list_replace_rcu(&leader->tasks, ¤t->tasks); | 708 | list_replace_rcu(&leader->tasks, &tsk->tasks); |
| 708 | 709 | ||
| 709 | current->group_leader = current; | 710 | tsk->group_leader = tsk; |
| 710 | leader->group_leader = current; | 711 | leader->group_leader = tsk; |
| 711 | 712 | ||
| 712 | /* Reduce leader to a thread */ | 713 | tsk->exit_signal = SIGCHLD; |
| 713 | detach_pid(leader, PIDTYPE_PGID); | ||
| 714 | detach_pid(leader, PIDTYPE_SID); | ||
| 715 | |||
| 716 | current->exit_signal = SIGCHLD; | ||
| 717 | 714 | ||
| 718 | BUG_ON(leader->exit_state != EXIT_ZOMBIE); | 715 | BUG_ON(leader->exit_state != EXIT_ZOMBIE); |
| 719 | leader->exit_state = EXIT_DEAD; | 716 | leader->exit_state = EXIT_DEAD; |
| @@ -753,7 +750,7 @@ no_thread_group: | |||
| 753 | spin_lock(&oldsighand->siglock); | 750 | spin_lock(&oldsighand->siglock); |
| 754 | spin_lock_nested(&newsighand->siglock, SINGLE_DEPTH_NESTING); | 751 | spin_lock_nested(&newsighand->siglock, SINGLE_DEPTH_NESTING); |
| 755 | 752 | ||
| 756 | rcu_assign_pointer(current->sighand, newsighand); | 753 | rcu_assign_pointer(tsk->sighand, newsighand); |
| 757 | recalc_sigpending(); | 754 | recalc_sigpending(); |
| 758 | 755 | ||
| 759 | spin_unlock(&newsighand->siglock); | 756 | spin_unlock(&newsighand->siglock); |
| @@ -764,7 +761,7 @@ no_thread_group: | |||
| 764 | kmem_cache_free(sighand_cachep, oldsighand); | 761 | kmem_cache_free(sighand_cachep, oldsighand); |
| 765 | } | 762 | } |
| 766 | 763 | ||
| 767 | BUG_ON(!thread_group_leader(current)); | 764 | BUG_ON(!thread_group_leader(tsk)); |
| 768 | return 0; | 765 | return 0; |
| 769 | } | 766 | } |
| 770 | 767 | ||
