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

Bug#505784: pthread_cancel(3): misleading information on cancellation points



Package: glibc-doc
Version: 2.7-15
Severity: normal
File: /usr/share/man/man3/pthread_cancel.3.gz

"""
POSIX specifies that a number of system calls (basically, all system calls that may block, such as read(2), write(2), wait(2), etc.) and library functions that may call these system calls (e.g. fprintf(3)) are cancellation points. LinuxThreads is not yet integrated enough with the C library to implement this, and thus none of the C library functions is a cancellation point.
"""

This is no longer true, as you can easily check with the attached program.

--
Jakub Wilk
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>

volatile int i;

void *start(void *p)
{
  i = 0;
  while (1)
  {
    putchar('.');
    i++;
  }
  return NULL;
}

int main()
{
  pthread_t thread;
  pthread_create(&thread, NULL, start, NULL);
  usleep(1 << 15);
  pthread_cancel(thread);
  pthread_join(thread, NULL);
  printf("\n%d\n", i);
  return 0;
}

/* vim:set ts=2 sw=2 et:*/

Reply to: