On Wed, 15 Jan 2003, Robert Collins wrote:

> On Wed, 2003-01-15 at 22:23, Thomas Pfaff wrote:
> > This patch will make sure that the signal handlers that are saved in the
> > system call are restored even if the thread got cancelled. Since
> > spawn_guts uses waitpid when mode is _P_WAIT spawn_guts is a cancellation
> > point.
> >
> > Attached is the patch and a new test case.
>
> The new test case doesn't appear to check that the signal handlers where
> saved. Am I misreading that?
>

The test case was created to prove that system is a cancellation point
even if the child process is already created and the system call is
waiting on child termination.

Atached are two test cases that will test if the signal handlers are
restored when the call get cancelled and has waited successfully for the
child.

Thomas
/*
 * File: cancel11.c
 *
 * Test Synopsis: Test if system is a cancellation point.
 *
 * Test Method (Validation or Falsification):
 * - 
 *
 * Requirements Tested:
 * -
 *
 * Features Tested:
 * - 
 *
 * Cases Tested:
 * - 
 *
 * Description:
 * - 
 *
 * Environment:
 * - 
 *
 * Input:
 * - None.
 *
 * Output:
 * - File name, Line number, and failed expression on failure.
 * - No output on success.
 *
 * Assumptions:
 * - have working pthread_create, pthread_cancel, pthread_setcancelstate
 *   pthread_join
 *
 * Pass Criteria:
 * - Process returns zero exit status.
 *
 * Fail Criteria:
 * - Process returns non-zero exit status.
 */

#include "test.h"

static void sig_handler(int sig)
{
}

static void *Thread(void *punused)
{
  system ("sleep 10");

  return NULL;
}

int main (void)
{
  void * result;
  pthread_t t;

  signal (SIGINT, sig_handler);

  assert (pthread_create (&t, NULL, Thread, NULL) == 0);
  sleep (5);
  assert (pthread_cancel (t) == 0);
  assert (pthread_join (t, &result) == 0);
  assert (result == PTHREAD_CANCELED);

  assert ((void *)signal (SIGINT, NULL) == sig_handler);

  return 0;
}
/*
 * File: cancel12.c
 *
 * Test Synopsis: Test if system is a cancellation point.
 *
 * Test Method (Validation or Falsification):
 * - 
 *
 * Requirements Tested:
 * -
 *
 * Features Tested:
 * - 
 *
 * Cases Tested:
 * - 
 *
 * Description:
 * - 
 *
 * Environment:
 * - 
 *
 * Input:
 * - None.
 *
 * Output:
 * - File name, Line number, and failed expression on failure.
 * - No output on success.
 *
 * Assumptions:
 * - have working pthread_create, pthread_cancel, pthread_setcancelstate
 *   pthread_join
 *
 * Pass Criteria:
 * - Process returns zero exit status.
 *
 * Fail Criteria:
 * - Process returns non-zero exit status.
 */

#include "test.h"

static void sig_handler(int sig)
{
}

static void *Thread(void *punused)
{
  signal (SIGINT, sig_handler);

  system ("sleep 5");

  assert ((void *)signal (SIGINT, NULL) == sig_handler);

  return NULL;
}

int main (void)
{
  void *old_sigh;
  void * result;
  pthread_t t;

  assert (pthread_create (&t, NULL, Thread, NULL) == 0);
  assert (pthread_join (t, &result) == 0);
  assert (result == NULL);

  return 0;
}

Reply via email to