Back to index

glibc  2.9
Functions | Variables
sigusr.c File Reference
#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

Go to the source code of this file.

Functions

void synch_signal (int sig)
void child_function (void)
int main (void)

Variables

volatile sig_atomic_t usr_interrupt = 0

Function Documentation

void child_function ( void  )

Definition at line 19 of file sigusr.c.

{
  /* Perform initialization. */
  printf ("I'm here!!!  My pid is %d.\n", (int) getpid ());

  /* Let parent know you're done. */
  kill (getppid (), SIGUSR1);

  /* Continue with execution. */
  puts ("Bye, now....");
  exit (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( void  )

Definition at line 33 of file sigusr.c.

{
  struct sigaction usr_action;
  sigset_t block_mask;
  pid_t child_id;

  /* Establish the signal handler. */
  sigfillset (&block_mask);
  usr_action.sa_handler = synch_signal;
  usr_action.sa_mask = block_mask;
  usr_action.sa_flags = 0;
  sigaction (SIGUSR1, &usr_action, NULL);

  /* Create the child process. */
  child_id = fork ();
  if (child_id == 0)
    child_function ();             /* Does not return.  */

/*@group*/
  /* Busy wait for the child to send a signal. */
  while (!usr_interrupt)
    ;
/*@end group*/

  /* Now continue execution. */
  puts ("That's all, folks!");

  return 0;
}

Here is the call graph for this function:

void synch_signal ( int  sig)

Definition at line 12 of file sigusr.c.

{
  usr_interrupt = 1;
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 9 of file sigusr.c.