Back to index

glibc  2.9
Defines | Functions | Variables
tst-signal5.c File Reference
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define TEST_FUNCTION   do_test ()

Functions

static void * tf (void *arg)
static int do_test (void)

Variables

static sigset_t ss

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 110 of file tst-signal5.c.


Function Documentation

static int do_test ( void  ) [static]

Definition at line 62 of file tst-signal5.c.

{
  sigemptyset (&ss);
  sigaddset (&ss, SIGUSR1);
  if (pthread_sigmask (SIG_SETMASK, &ss, NULL) != 0)
    {
      puts ("1st sigmask failed");
      exit (1);
    }

  pthread_t th;
  if (pthread_create (&th, NULL, tf, NULL) != 0)
    {
      puts ("1st create failed");
      exit (1);
    }

  void *r;
  if (pthread_join (th, &r) != 0)
    {
      puts ("1st join failed");
      exit (1);
    }

  sigemptyset (&ss);
  sigaddset (&ss, SIGUSR2);
  sigaddset (&ss, SIGFPE);
  if (pthread_sigmask (SIG_SETMASK, &ss, NULL) != 0)
    {
      puts ("2nd sigmask failed");
      exit (1);
    }

  if (pthread_create (&th, NULL, tf, NULL) != 0)
    {
      puts ("2nd create failed");
      exit (1);
    }

  if (pthread_join (th, &r) != 0)
    {
      puts ("2nd join failed");
      exit (1);
    }

  return 0;
}

Here is the call graph for this function:

static void* tf ( void *  arg) [static]

Definition at line 35 of file tst-signal5.c.

{
  sigset_t ss2;
  if (pthread_sigmask (SIG_SETMASK, NULL, &ss2) != 0)
    {
      puts ("child: sigmask failed");
      exit (1);
    }

  int i;
  for (i = 1; i < 32; ++i)
    if (sigismember (&ss, i) && ! sigismember (&ss2, i))
      {
       printf ("signal %d set in parent mask, but not in child\n", i);
       exit (1);
      }
    else if (! sigismember (&ss, i) && sigismember (&ss2, i))
      {
       printf ("signal %d set in child mask, but not in parent\n", i);
       exit (1);
      }

  return NULL;
}

Here is the call graph for this function:


Variable Documentation

sigset_t ss [static]

Definition at line 31 of file tst-signal5.c.