C语言版本
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/wait.h>
#include<sys/types.h>
int main()
{
FILE *fp=NULL;
int c;
int upper=0;
int lower = 0;
pid_t cpid,pr;
int status;
cpid = fork();
if(cpid <0)
printf("fork() error");
else if(cpid == 0)
{
printf("this is child process\n");
fp =fopen("in.txt","r");
while((c = getc(fp)) != EOF)
{
if( c>='A'&& c<='Z')
upper++;
}
fclose(fp);
printf("upper:%d\n",upper);
exit(0);
}else{
printf("this is parent process\n");
if(pr = wait(&status))
{
fp = fopen("in.txt","r");
while((c = getc(fp))!= EOF)
{
if(c>='a' &&c<='z')
lower++;
}
fclose(fp);
printf("lower:%d\n",lower);
}
}
return 0;
}