Back to index

glibc  2.9
Defines | Functions
tst-sem6.c File Reference
#include <errno.h>
#include <semaphore.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define TIMEOUT   3
#define TEST_FUNCTION   do_test ()

Functions

static void handler (int sig)
static int do_test (void)

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 80 of file tst-sem6.c.

#define TIMEOUT   3

Definition at line 79 of file tst-sem6.c.


Function Documentation

static int do_test ( void  ) [static]

Definition at line 44 of file tst-sem6.c.

{
  sem_t s;
  struct sigaction sa;

  sa.sa_handler = handler;
  sa.sa_flags = 0;
  sigemptyset (&sa.sa_mask);

  sigaction (SIGALRM, &sa, NULL);

  if (sem_init (&s, 0, 0) == -1)
    {
      puts ("init failed");
      return 1;
    }

  /* Set an alarm for 1 second.  The wrapper will expect this.  */
  alarm (1);

  int res = sem_wait (&s);
  if (res == 0)
    {
      puts ("wait succeeded");
      return 1;
    }
  if (res != -1 || errno != EINTR)
    {
      puts ("wait didn't fail with EINTR");
      return 1;
    }

  return 0;
}

Here is the call graph for this function:

static void handler ( int  sig) [static]

Definition at line 28 of file tst-sem6.c.

{
  struct sigaction sa;

  sa.sa_handler = SIG_DFL;
  sa.sa_flags = 0;
  sigemptyset (&sa.sa_mask);

  sigaction (SIGALRM, &sa, NULL);

  /* Rearm the timer.  */
  alarm (1);
}

Here is the call graph for this function: