Merge tag 'arc-5.10-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupt...
[linux-2.6-microblaze.git] / kernel / exit.c
index 733e80f..87a2d51 100644 (file)
@@ -1474,23 +1474,6 @@ end:
        return retval;
 }
 
-static struct pid *pidfd_get_pid(unsigned int fd)
-{
-       struct fd f;
-       struct pid *pid;
-
-       f = fdget(fd);
-       if (!f.file)
-               return ERR_PTR(-EBADF);
-
-       pid = pidfd_pid(f.file);
-       if (!IS_ERR(pid))
-               get_pid(pid);
-
-       fdput(f);
-       return pid;
-}
-
 static long kernel_waitid(int which, pid_t upid, struct waitid_info *infop,
                          int options, struct rusage *ru)
 {
@@ -1498,6 +1481,7 @@ static long kernel_waitid(int which, pid_t upid, struct waitid_info *infop,
        struct pid *pid = NULL;
        enum pid_type type;
        long ret;
+       unsigned int f_flags = 0;
 
        if (options & ~(WNOHANG|WNOWAIT|WEXITED|WSTOPPED|WCONTINUED|
                        __WNOTHREAD|__WCLONE|__WALL))
@@ -1531,9 +1515,10 @@ static long kernel_waitid(int which, pid_t upid, struct waitid_info *infop,
                if (upid < 0)
                        return -EINVAL;
 
-               pid = pidfd_get_pid(upid);
+               pid = pidfd_get_pid(upid, &f_flags);
                if (IS_ERR(pid))
                        return PTR_ERR(pid);
+
                break;
        default:
                return -EINVAL;
@@ -1544,7 +1529,12 @@ static long kernel_waitid(int which, pid_t upid, struct waitid_info *infop,
        wo.wo_flags     = options;
        wo.wo_info      = infop;
        wo.wo_rusage    = ru;
+       if (f_flags & O_NONBLOCK)
+               wo.wo_flags |= WNOHANG;
+
        ret = do_wait(&wo);
+       if (!ret && !(options & WNOHANG) && (f_flags & O_NONBLOCK))
+               ret = -EAGAIN;
 
        put_pid(pid);
        return ret;