]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/exit.c
h63xx: tsc2101 alsa sound support
[linux-2.6-omap-h63xx.git] / kernel / exit.c
index 452a1d1161782130204c934542aa2cb7f5f44b25..531aadca553030543b643a0553f6144785d02bb5 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/interrupt.h>
 #include <linux/smp_lock.h>
 #include <linux/module.h>
+#include <linux/capability.h>
 #include <linux/completion.h>
 #include <linux/personality.h>
 #include <linux/tty.h>
@@ -29,6 +30,7 @@
 #include <linux/syscalls.h>
 #include <linux/signal.h>
 #include <linux/cn_proc.h>
+#include <linux/mutex.h>
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
@@ -72,7 +74,6 @@ repeat:
                __ptrace_unlink(p);
        BUG_ON(!list_empty(&p->ptrace_list) || !list_empty(&p->ptrace_children));
        __exit_signal(p);
-       __exit_sighand(p);
        /*
         * Note that the fastpath in sys_times depends on __exit_signal having
         * updated the counters before a task is removed from the tasklist of
@@ -192,7 +193,7 @@ int is_orphaned_pgrp(int pgrp)
        return retval;
 }
 
-static inline int has_stopped_jobs(int pgrp)
+static int has_stopped_jobs(int pgrp)
 {
        int retval = 0;
        struct task_struct *p;
@@ -229,7 +230,7 @@ static inline int has_stopped_jobs(int pgrp)
  *
  * NOTE that reparent_to_init() gives the caller full capabilities.
  */
-static inline void reparent_to_init(void)
+static void reparent_to_init(void)
 {
        write_lock_irq(&tasklist_lock);
 
@@ -243,7 +244,9 @@ static inline void reparent_to_init(void)
        /* Set the exit signal to SIGCHLD so we signal init on exit */
        current->exit_signal = SIGCHLD;
 
-       if ((current->policy == SCHED_NORMAL) && (task_nice(current) < 0))
+       if ((current->policy == SCHED_NORMAL ||
+                       current->policy == SCHED_BATCH)
+                               && (task_nice(current) < 0))
                set_user_nice(current, 0);
        /* cpus_allowed? */
        /* rt_priority? */
@@ -258,7 +261,7 @@ static inline void reparent_to_init(void)
 
 void __set_special_pids(pid_t session, pid_t pgrp)
 {
-       struct task_struct *curr = current;
+       struct task_struct *curr = current->group_leader;
 
        if (curr->signal->session != session) {
                detach_pid(curr, PIDTYPE_SID);
@@ -357,6 +360,9 @@ void daemonize(const char *name, ...)
        fs = init_task.fs;
        current->fs = fs;
        atomic_inc(&fs->count);
+       exit_namespace(current);
+       current->namespace = init_task.namespace;
+       get_namespace(current->namespace);
        exit_files(current);
        current->files = init_task.files;
        atomic_inc(&current->files->count);
@@ -366,7 +372,7 @@ void daemonize(const char *name, ...)
 
 EXPORT_SYMBOL(daemonize);
 
-static inline void close_files(struct files_struct * files)
+static void close_files(struct files_struct * files)
 {
        int i, j;
        struct fdtable *fdt;
@@ -540,7 +546,7 @@ static inline void choose_new_parent(task_t *p, task_t *reaper, task_t *child_re
        p->real_parent = reaper;
 }
 
-static inline void reparent_thread(task_t *p, task_t *father, int traced)
+static void reparent_thread(task_t *p, task_t *father, int traced)
 {
        /* We don't want people slaying init.  */
        if (p->exit_signal != -1)
@@ -604,7 +610,7 @@ static inline void reparent_thread(task_t *p, task_t *father, int traced)
  * group, and if no such member exists, give it to
  * the global child reaper process (ie "init")
  */
-static inline void forget_original_parent(struct task_struct * father,
+static void forget_original_parent(struct task_struct * father,
                                          struct list_head *to_release)
 {
        struct task_struct *p, *reaper = father;
@@ -842,7 +848,7 @@ fastcall NORET_TYPE void do_exit(long code)
        }
        group_dead = atomic_dec_and_test(&tsk->signal->live);
        if (group_dead) {
-               del_timer_sync(&tsk->signal->real_timer);
+               hrtimer_cancel(&tsk->signal->real_timer);
                exit_itimers(tsk->signal);
                acct_process(code);
        }
@@ -859,7 +865,7 @@ fastcall NORET_TYPE void do_exit(long code)
        if (group_dead && tsk->signal->leader)
                disassociate_ctty(1);
 
-       module_put(tsk->thread_info->exec_domain->module);
+       module_put(task_thread_info(tsk)->exec_domain->module);
        if (tsk->binfmt)
                module_put(tsk->binfmt->module);
 
@@ -870,6 +876,10 @@ fastcall NORET_TYPE void do_exit(long code)
        mpol_free(tsk->mempolicy);
        tsk->mempolicy = NULL;
 #endif
+       /*
+        * If DEBUG_MUTEXES is on, make sure we are holding no locks:
+        */
+       mutex_debug_check_no_locks_held(tsk);
 
        /* PF_DEAD causes final put_task_struct after we schedule. */
        preempt_disable();
@@ -926,7 +936,6 @@ do_group_exit(int exit_code)
                        /* Another thread got here before we took the lock.  */
                        exit_code = sig->group_exit_code;
                else {
-                       sig->flags = SIGNAL_GROUP_EXIT;
                        sig->group_exit_code = exit_code;
                        zap_other_threads(current);
                }
@@ -1068,6 +1077,9 @@ static int wait_task_zombie(task_t *p, int noreap,
        }
 
        if (likely(p->real_parent == p->parent) && likely(p->signal)) {
+               struct signal_struct *psig;
+               struct signal_struct *sig;
+
                /*
                 * The resource counters for the group leader are in its
                 * own task_struct.  Those for dead threads in the group
@@ -1084,24 +1096,26 @@ static int wait_task_zombie(task_t *p, int noreap,
                 * here reaping other children at the same time.
                 */
                spin_lock_irq(&p->parent->sighand->siglock);
-               p->parent->signal->cutime =
-                       cputime_add(p->parent->signal->cutime,
+               psig = p->parent->signal;
+               sig = p->signal;
+               psig->cutime =
+                       cputime_add(psig->cutime,
                        cputime_add(p->utime,
-                       cputime_add(p->signal->utime,
-                                   p->signal->cutime)));
-               p->parent->signal->cstime =
-                       cputime_add(p->parent->signal->cstime,
+                       cputime_add(sig->utime,
+                                   sig->cutime)));
+               psig->cstime =
+                       cputime_add(psig->cstime,
                        cputime_add(p->stime,
-                       cputime_add(p->signal->stime,
-                                   p->signal->cstime)));
-               p->parent->signal->cmin_flt +=
-                       p->min_flt + p->signal->min_flt + p->signal->cmin_flt;
-               p->parent->signal->cmaj_flt +=
-                       p->maj_flt + p->signal->maj_flt + p->signal->cmaj_flt;
-               p->parent->signal->cnvcsw +=
-                       p->nvcsw + p->signal->nvcsw + p->signal->cnvcsw;
-               p->parent->signal->cnivcsw +=
-                       p->nivcsw + p->signal->nivcsw + p->signal->cnivcsw;
+                       cputime_add(sig->stime,
+                                   sig->cstime)));
+               psig->cmin_flt +=
+                       p->min_flt + sig->min_flt + sig->cmin_flt;
+               psig->cmaj_flt +=
+                       p->maj_flt + sig->maj_flt + sig->cmaj_flt;
+               psig->cnvcsw +=
+                       p->nvcsw + sig->nvcsw + sig->cnvcsw;
+               psig->cnivcsw +=
+                       p->nivcsw + sig->nivcsw + sig->cnivcsw;
                spin_unlock_irq(&p->parent->sighand->siglock);
        }