signals.c
author viric@llimona
Fri, 14 Sep 2007 22:26:58 +0200
changeset 12 6a372f8b4b8a
parent 7 af8d59476914
permissions -rw-r--r--
Ignore, license and version.

/*
    stdin mix - a mixer/multiplexer for stdin to processes
    Copyright (C) 2007  LluĂ­s Batlle i Rossell

    Please find the license in the provided COPYING file.
*/
#include <signal.h>

#include "main.h"

static int child;

static void forward_signals_to_child_handler(int val)
{
    kill(child, val);
}

int install_signal_forwarders(int _child)
{
  struct sigaction act;

  child = _child;

  act.sa_handler = forward_signals_to_child_handler;
  /* Reset the mask */
  memset(&act.sa_mask,0,sizeof(act.sa_mask));
  act.sa_flags = 0;

  sigaction(SIGTERM, &act, 0);
  sigaction(SIGINT, &act, 0);
}