所以我在看着我的教授的代码,他分发给我们一个如何实现的想法>,<,|支持到我们的unix shell。我运行他的代码,并对实际发生的事情感到惊讶。execlp如何正确工作?
if(pid == 0)
{
close(1); // close
fd = creat("userlist", 0644); // then open
execlp("who", "who", NULL); // and run
perror("execlp");
exit(1);
}
这造成了我目前在目录中的用户列表文件,与该文件中的“谁”的数据。我没有看到fd和execlp之间的连接在哪里。 execlp如何设法将信息放入用户列表中? execlp如何知道用户列表存在?