Back to index

glibc  2.9
Defines | Functions
tst-mallocfork.c File Reference
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.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 sig_handler (int signum)
static int do_test (void)

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 50 of file tst-mallocfork.c.


Function Documentation

static int do_test ( void  ) [static]

Definition at line 21 of file tst-mallocfork.c.

{
  pid_t parent = getpid ();

  struct sigaction action = { .sa_handler = sig_handler };
  sigemptyset (&action.sa_mask);

  malloc (sizeof (int));

  if (sigaction (SIGALRM, &action, NULL) != 0)
    {
      puts ("sigaction failed");
      return 1;
    }

  /* Create a child that sends the signal to be caught.  */
  pid_t child = fork ();
  if (child == 0)
    {
      if (kill (parent, SIGALRM) == -1)
       perror ("kill");
      exit (0);
    }

  TEMP_FAILURE_RETRY (waitpid (child, NULL, 0));

  return 0;
}

Here is the call graph for this function:

static void sig_handler ( int  signum) [static]

Definition at line 12 of file tst-mallocfork.c.

{
  pid_t child = fork ();
  if (child == 0)
    exit (0);
  TEMP_FAILURE_RETRY (waitpid (child, NULL, 0));
}

Here is the call graph for this function:

Here is the caller graph for this function: