summaryrefslogtreecommitdiffstats
path: root/samples/pidfd/pidfd-metadata.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2019-07-08 18:04:41 +0200
committerIngo Molnar <mingo@kernel.org>2019-07-08 18:04:41 +0200
commit552a031ba12a4236be107a5b082a399237758a5d (patch)
treea2bcdeb651b360013dbb654bbcd61dbaf51e0331 /samples/pidfd/pidfd-metadata.c
parentMerge branch 'x86/cpu' into perf/core, to pick up revert (diff)
parentLinux 5.2 (diff)
downloadlinux-552a031ba12a4236be107a5b082a399237758a5d.tar.xz
linux-552a031ba12a4236be107a5b082a399237758a5d.zip
Merge tag 'v5.2' into perf/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'samples/pidfd/pidfd-metadata.c')
-rw-r--r--samples/pidfd/pidfd-metadata.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/samples/pidfd/pidfd-metadata.c b/samples/pidfd/pidfd-metadata.c
index 14b454448429..c459155daf9a 100644
--- a/samples/pidfd/pidfd-metadata.c
+++ b/samples/pidfd/pidfd-metadata.c
@@ -83,7 +83,7 @@ static int pidfd_metadata_fd(pid_t pid, int pidfd)
int main(int argc, char *argv[])
{
- int pidfd = 0, ret = EXIT_FAILURE;
+ int pidfd = -1, ret = EXIT_FAILURE;
char buf[4096] = { 0 };
pid_t pid;
int procfd, statusfd;
@@ -91,7 +91,11 @@ int main(int argc, char *argv[])
pid = pidfd_clone(CLONE_PIDFD, &pidfd);
if (pid < 0)
- exit(ret);
+ err(ret, "CLONE_PIDFD");
+ if (pidfd == -1) {
+ warnx("CLONE_PIDFD is not supported by the kernel");
+ goto out;
+ }
procfd = pidfd_metadata_fd(pid, pidfd);
close(pidfd);