Thanks in advance for any one who helps me.
Code is in C using unix system calls.
I am writing a code that forks a process and that forked process gets worked on by a function, in my case its called processone. I had a similar program, in which i passed a int value to processone and it worked, however, when i passed a char value to processone it went all buggy and my debugger says that the statement "else if ( forkedpid == 0 )" was useless. Then when I run it, the else if statement is totally ignored, even a print statement would not work with that else if statement. Am i not allowed to pass a char or string into process one? I don't see how that wold effect the statement.
Below is my code
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
void processone(int delay);
void processtwo();
int main(int ac, char* av[]){
pid_t forkedpid;
if ( (forkedpid = fork()) == -1 )
perror("fork problem");
else if ( forkedpid == 0 ) /*the problem is here*/
processone(av[1]);/*av[1] is a user input, char*/
else
processtwo(forkedpid);
return 0;
}
void processone(char avinput){
printf("processone does soemthing with %s",avinput);
exit(10);
}
void processtwo(){
printf("processtwo does soemthing");
}