日期:2014-05-16  浏览次数:20620 次

考试时间真的不多啦,各位大大一定要救救我啊,C实现UNIX功能,急急急。。。。。- -!
/*文件名:sysc.c */
#include <sys/stat.h>
#include <unistd.h>
main(int argc,char *argv[])
{
struct stat sb;
int pid,status,r;
pid=/* 此处补充程序 */ ;
if(pid>0)
{
pid=wait((&status);
printf("Parent Process OK\n");
}
else  
{
r=/* 此处补充程序 */;
if(r==0)
print ("size=%d\nChild Process OK\n",sb.st_size);
}

}

令以上程序文件名为a.c它创建并等待子进程完成Unix系统的获取文件信息系统调用。
指定文件名为a.c,获取信息为该文件的长度信息。

------解决方案--------------------
第一个
pid = fork();

第二个
r = stat("a.c", &sb);