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");
}

> void processone(int delay);
This is an int

> processone(av[1]);
This is a char*

> void processone(char avinput)
This is a char

Making prototype AND definition a char* as well would go a LONG way.

Sorry about that error. My original has the correct changes from int to char. However, still gotten the same error. My real code has a lot more code. This is just a skeleton.

Move the fork outside any if .

> This is just a skeleton.
In other words, a complete waste of time.

Post an accurate facsimile of your actual problem, and you might get some useful answers.

Post random dribble in a half-assed attempt to paraphrase the problem and you're going to get equally off-target and useless answers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.