Hey just thought some of the user might be able to shed some light on my situation. So im working with forks and creating 2 fork processes. One child and parent. What im trying to get the child to ask me for a value. Then the parent would start to figure out the value and keep trying. Once it figures it out its tells them you got it and simply stops the program. I cant seem to get the program to keep guessing and stop when the number is found which sends a sigint. Here's what i have so far.
Code:
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <stdbool.h>
int main() {
int j, i,pid;
bool p= true;
int input;
printf("Fork\n");
// clone process
j = fork();
//child
if (pid == 0) {
while(true){
if(!p){
printf("Enter a value");
scanf("%d", &input); }}}
//parent
else {
while (input == 1) {
printf("%s\n", "you got it");
}}}