Skip to content

Commit

Permalink
attach: simplify opening of /proc/self
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Feb 1, 2021
1 parent 4475fab commit 595798b
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/lxc/attach.c
Expand Up @@ -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");

Expand Down

0 comments on commit 595798b

Please sign in to comment.