bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

thread/fork


From: Ling Gou
Subject: thread/fork
Date: Fri, 25 Jan 2002 17:14:10 -0800

Hi Andreas,

Thanks for you reply.

Now I am doing some testing on thread and fork as in the following code.
The problem is that HELLOWORLD will not be shown.  It seems execlp never get 
exec_ed.
Regards,
Ling

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>

static
void *thread_function(void *arg) {
    int i;
    int status;
    for ( i=0; i<3; i++ ) {
printf("Thread says hi = %d\n", i);
    }
    return NULL;
 }

int main(void)
{
  pid_t pid;

  pthread_t new_thread;
  pthread_create(&new_thread, NULL,  thread_function, NULL);
  pid = fork ();
  if (pid == 0) {
     execlp("echo", "echo", "HELLOWORLD", NULL);
    _exit(-1);
  }

  printf("main func\n");
  while(1);
  return 0;
}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]