我使用ac文件中的execvp系统调用调用了“ ls”命令。但是似乎有细微的差别。
默认ls调用中的exe文件突出显示为绿色,但在我自己的execvp ls调用中却没有。我想念什么吗?
这是调用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");
}
ls
您的shell中的别名是ls --color=auto
:
$ alias ls
alias ls='ls --color=auto'
如果要在ls
输出中着色,请使用该--color
选项。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句