题目
通过fork()创建子进程,在子进程下输出下列文件student.txt中每个学生的最高成绩,每行包含学号,姓名,c++成绩,操作系统成绩,数据库成绩
student.txt文件的具体内容如下:
1001 zhangsan 88 89 90
1002 lisi 87 91 92
1003 wangwu 78 80 87
1004 zhaoliu 88 81 92
父进程一直等待子进程结束后发送的SIGCHLD信号,然后结束退出。
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <signal.h>
struct student{
int id;
char * name[20];
int a;
int b;
int c;
};
void sys_err(char* str)
{
perror(str);
exit(1);
}
void do_sig_child(int signo)