默认“ ls”和execvp“ ls”调用的区别

炼金术士

我使用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");
}
muru

ls您的shell中的别名是ls --color=auto

$ alias ls
alias ls='ls --color=auto'

如果要在ls输出中着色,请使用该--color选项。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章