yeah my bad. Does this look a bit better at all..?
Code:
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
pid_t pid;
FILE *fp;
int count = 0;
int no_lines = 0;
for (int i=0; i < argc; i++) {
pid = fork();
if(pid == 0)
{
if (access(pid, R_OK) != -1) {
fp = fopen(pid, "r");
for (c=getc(fp); c != EOF; c=getc(fp)) {
if (c == '\n') {
count = count + 1;
}
}
fclose(fp);
if ((count % 2) == 0) {
exit(0)
}
else {
exit(1)
}
}
else {
exit(-1)
}
}
else
{
// Do parent's job
}
}
}