pthread_create: Arg is'nt submitted to function

Asked by kaiszy

Hi!

I have written a small programm that uses pthread. A piece of code:

main.c

args = calloc(1,sizeof(struct threadArgs));

args->socket = i;

if(pthread_create(&thread, NULL, (void *)thread_reader, (void *)args)) {

  errorHandling;
}

void *thread_reader(void *arg[]) {

 struct threadArgs *args;

 int sock;

 if(args == NULL) {

  printf("No args, no fun\n");

  return NULL;

 }

        DoSomething();
}

If i compile the programm on debian etch amd64 everything works fine. If i compile the programm on Ubuntu 8.10 intrepid i get the message: "No args, no fun".

On both system i have installed the latest updates.

Thanks for your afford!

Best regards,
  Kai.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
kaiszy
Solved:
Last query:
Last reply:
Revision history for this message
kaiszy (kai-szymanski) said :
#1

Hi!

Sorry for my mistake...args and arg is not the same :) If i change:

void *thread_reader(void *arg[]) {

 struct threadArgs *args = arg;

it works on Ubuntu. But why does it work with debian etch without change ?

Best regards,
  Kai.