/* sys/raise.c (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes */

#include <sys/emx.h>
#define INCL_DOSEXCEPTIONS
#include <os2emx.h>
#include <string.h>
#include <signal.h>
#include <errno.h>
#include "syscalls.h"

int __raise (int signo)
{
  thread_data *tp;

  if (signo < 1 || signo >= NSIG || !_sys_sig_valid[signo])
    {
      errno = EINVAL;
      return (-1);
    }
  tp = SYS_THREAD;
  if (tp == NULL)
    {
      errno = EINVAL;
      return (-1);
    }
  if (tp->sig_ack_req[signo])
    tp->sig_pending[signo] = 1;
  else if (tp->sig_handlers[signo] != SIG_IGN)
    {
      tp->sig_ack_req[signo] = 1;
      _sys_signal (signo, FALSE);
    }
  return (0);
}
