This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

pthread detach problem with glibc 2.2 on SMP



The following program compiled with:
gcc -o pthread-test -g -O2 pthread-test.c -lpthread -Wall

gives sometimes (try it at least 20 times) on an SMP system as result:
abc: Interrupted system call
def: Invalid argument

with an exit status of 15.  I'm running glibc 2.2 here.

Has anybody an idea how to fix this?

Thanks,
Andreas

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

static void *
task (void *p)
{
  return (void *) (p == NULL);
}

int
main (void)
{
  pthread_t t;
  int status;

  /* make sure pthread_create() isn't just a stub */
  status = 0;
  status = pthread_create (&t, NULL, task, NULL);
  if (status)
    {
      perror ("foo");
      exit (status * 3);
    }

  /* make sure pthread_detach() isn't just a stub */
  status = pthread_detach (t) * 5;
  if (status)
    perror ("abc");

  pthread_kill_other_threads_np ();
  if (status)
    perror ("def");

  exit (status);

  return 0;
}

-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]