Я вызвал команду «ls», используя системный вызов execvp изнутри c-файла. Но, кажется, есть небольшая разница.
Файлы exe в вызове по умолчанию ls выделены зеленым цветом, но не в моем собственном вызове execvp.
Это фрагмент кода, который вызывает ls.
else if (rc == 0)
{
// child (new process)
printf("hello, I am child (pid:%d)\n", (int) getpid());
char *myargs[2];
myargs[0] = strdup("ls");
// program: "wc" (word count)
myargs[1] = NULL;//strdup("p3.c"); // argument: file to count
//myargs[2] = NULL;
// marks end of array
execvp(myargs[0], myargs); // runs word count
printf("this shouldn’t print out");
}