My C programming skill aren't the greatest, but I see things which do not conform to what I was taught.
Code:
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
volatile int i=0;
void child(){
i++;
printf("i in child is %d \n",i);
kill(getpid(),SIGKILL);
}
int main()
You have the function definition placed where the function prototype should be. Furthermore, the function is defined as void child (void), meaning it receives nothing and returns nothing.
Code:
void child(){
i++;
printf("i in child is %d \n",i);
kill(getpid(),SIGKILL);}
Perhaps some rearranging might help.
Code:
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
*/prototype declatartion - change child() to type int
int child();
volatile int i=0;
int main()
{
pid_t pid;
printf("fork program starting\n");
pid = fork();
if (pid==0)
child();
else wait(NULL);
printf("i in parent is %d \n",i);
}
/* function definition relocated after main(), defined as type int /*
int child(){
i++;
printf("i in child is %d \n",i);
kill(getpid(),SIGKILL);
return i;
}
A void function returns nothing; an int function returns an interer value.
Now you need to finish the correction to use the return value.