Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
[pandora-kernel.git] / fs / signalfd.c
index f1da892..a8e293d 100644 (file)
@@ -56,12 +56,18 @@ static int signalfd_lock(struct signalfd_ctx *ctx, struct signalfd_lockctx *lk)
                sighand = lock_task_sighand(lk->tsk, &lk->flags);
        rcu_read_unlock();
 
-       if (sighand && !ctx->tsk) {
+       if (!sighand)
+               return 0;
+
+       if (!ctx->tsk) {
                unlock_task_sighand(lk->tsk, &lk->flags);
-               sighand = NULL;
+               return 0;
        }
 
-       return sighand != NULL;
+       if (lk->tsk->tgid == current->tgid)
+               lk->tsk = current;
+
+       return 1;
 }
 
 static void signalfd_unlock(struct signalfd_lockctx *lk)
@@ -133,7 +139,8 @@ static unsigned int signalfd_poll(struct file *file, poll_table *wait)
         * the peer disconnects.
         */
        if (signalfd_lock(ctx, &lk)) {
-               if (next_signal(&lk.tsk->pending, &ctx->sigmask) > 0 ||
+               if ((lk.tsk == current &&
+                    next_signal(&lk.tsk->pending, &ctx->sigmask) > 0) ||
                    next_signal(&lk.tsk->signal->shared_pending,
                                &ctx->sigmask) > 0)
                        events |= POLLIN;
@@ -319,7 +326,7 @@ asmlinkage long sys_signalfd(int ufd, sigset_t __user *user_mask, size_t sizemas
 
        if (sizemask != sizeof(sigset_t) ||
            copy_from_user(&sigmask, user_mask, sizeof(sigmask)))
-               return error = -EINVAL;
+               return -EINVAL;
        sigdelsetmask(&sigmask, sigmask(SIGKILL) | sigmask(SIGSTOP));
        signotset(&sigmask);
 
@@ -330,7 +337,7 @@ asmlinkage long sys_signalfd(int ufd, sigset_t __user *user_mask, size_t sizemas
 
                init_waitqueue_head(&ctx->wqh);
                ctx->sigmask = sigmask;
-               ctx->tsk = current;
+               ctx->tsk = current->group_leader;
 
                sighand = current->sighand;
                /*