[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 0/2] linux-user: handle /proc/self/exe with execve() sysca
From: |
Michael Tokarev |
Subject: |
Re: [PATCH v2 0/2] linux-user: handle /proc/self/exe with execve() syscall |
Date: |
Thu, 27 Oct 2022 13:42:28 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 |
27.10.2022 09:40, Laurent Vivier wrote:
..
I tried O_CLOEXEC, but it seems the fd is closed before it is needed by execveat() to re-spawn the process, so it exits with an error (something like
EBADF)
It works here for me with a simple test program:
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/syscall.h>
#define AT_EMPTY_PATH 0x1000
static char *argv[] = { "ls", NULL };
static char *envp[] = { NULL };
int main(void) {
int fd = open("/usr/bin/ls", O_RDONLY);
fcntl(fd, F_SETFD, O_CLOEXEC);
//execveat(fd, "", argv, envp, AT_EMPTY_PATH);
syscall(__NR_execveat, fd, "", argv, envp, AT_EMPTY_PATH);
return 0;
}
/mjt