koraa / pipe_exec

Execute binaries from pipes, stdin and ttys
MIT License
66 stars 6 forks source link

Port to OS X and Freebsd #2

Open koraa opened 5 years ago

koraa commented 5 years ago

This will require feature testing to be done (see https://github.com/koraa/pipe_exec/tree/karo/feature-testing):

When fexecve & memfd_create is not available, we should:

  1. if stdin is a normal file, determine it's path and start using execve
  2. Otherwise use a temporary file in /tmp/ and if that fails try $HOME

When just memfd_create is missing we should:

  1. Try to execute the fd using fexecve
  2. Otherwise use a temporary file in /tmp/ and if that fails try $HOME

Using a temporary file should work like this:

  1. Create a temp file in /tmp/ using a random name
  2. Fill using transfer_mmap
  3. Make executable
  4. Fork a subprocess
  5. In main process, use execve
  6. In fork, wait for the main process to execve and then unlink the file

The signaling mechanism between main and fork needs to be determined…