From 595798bbcae788d38390ccd457269c6632344928 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Mon, 1 Feb 2021 12:23:26 +0100 Subject: [PATCH] attach: simplify opening of /proc/self Signed-off-by: Christian Brauner --- src/lxc/attach.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/lxc/attach.c b/src/lxc/attach.c index 6af3bdf64..3543ad331 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -361,11 +361,7 @@ static int get_attach_context(struct attach_context *ctx, if (ctx->init_pid < 0) return log_error(-1, "Failed to get init pid"); - ret = snprintf(path, sizeof(path), "/proc/%d", lxc_raw_getpid()); - if (ret < 0 || ret >= sizeof(path)) - return ret_errno(EIO); - - ctx->dfd_self_pid = openat(-EBADF, path, O_CLOEXEC | O_NOCTTY | O_NOFOLLOW | O_PATH | O_DIRECTORY); + ctx->dfd_self_pid = openat(-EBADF, "/proc/self", O_CLOEXEC | O_NOCTTY | O_PATH | O_DIRECTORY); if (ctx->dfd_self_pid < 0) return log_error_errno(-errno, errno, "Failed to open /proc/self"); -- 2.47.3