mrrl

Minimal Reliable Reproducible Linux
git clone https://ccx.te2000.cz/git/mrrl
Log | Files | Refs | Submodules | README

argv0exec.c (332B)


      1 #include <skalibs/exec.h>
      2 
      3 int main (int argc, const char const **argv)
      4 {
      5   const char *new_argv[argc + 1];
      6   for(size_t i = 0; i < argc; i++) {
      7     new_argv[i] = argv[i];
      8   }
      9   new_argv[argc] = 0;
     10 
     11   for(size_t i = 0; argv[0][i]; i++) {
     12     if(argv[0][i] == '/') {
     13       new_argv[0] = &argv[0][i+1];
     14     }
     15   }
     16   xexec(new_argv);
     17 }