0

I tried to run an program, which use container and execvp() function.

When I'm trying to run in the CLion, the program works fine, but when I'm running in my shell, it doesn't work, even when I use CLION's compile file. it says: "no such file or directory".

Any idea? the arguments that I use looks OK in the two options.

  • which directory are you in for each (CLion and shell)? Is it the same? Does CLion add something to your PATH? – Esther Jun 07 '22 at 19:40
  • @Esther Actually I use chroot(), chdir() and mount()' functions during the calling function, so it should work in the same way. I am also running it from the same diretcory. I don't know if CLion add something to PATH, how can I check it? – Yechiel Merzbach Jun 07 '22 at 19:50
  • Maybe try `which ` to see if it's found? Are you taking user input, where [this](https://stackoverflow.com/questions/33712971/execvp-no-such-file-or-directory) may apply? – Esther Jun 07 '22 at 19:54
  • @Esther I can see the file (for example /bin/bash) in the directory (that I swtich to), so it's found. I put the same input in CLion and terminal, and I checkd the exec and it's fine in both. – Yechiel Merzbach Jun 07 '22 at 19:58
  • sometimes files in the current directory don't get found in `$PATH` by default. I'm searching now if CLion adds cwd to PATH by default or something like that. – Esther Jun 07 '22 at 19:59
  • Otherwise try ./ and see if that works – Esther Jun 07 '22 at 20:03

1 Answers1

0

After a long time, I understand what was the problem. I used clone() function to create child to the main process, and I used not right flags.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459