Exemplo n.º 1
0
Arquivo: sig.c Projeto: hankem/jed
/* This should only be called from outside disturbance */
void sig_sys_spawn_cmd(int sig) /*{{{*/
{
   sig = errno;
   Signal_Sys_Spawn_Flag = 1;
   SLsignal_intr (SIGTSTP, sig_sys_spawn_cmd);
   errno = sig;
}
Exemplo n.º 2
0
static void sig_winch_handler (int sig)
{
   sig = errno;
   Want_Window_Size_Change = 1;
   SLsignal_intr (SIGWINCH, sig_winch_handler);
   errno = sig;
}
Exemplo n.º 3
0
/* This function will cause system calls to be restarted after signal if possible */
SLSig_Fun_Type *SLsignal (int sig, SLSig_Fun_Type *f)
{
#if defined(SLANG_POSIX_SIGNALS)
   struct sigaction old_sa, new_sa;

# ifdef SIGALRM
   /* We want system calls to be interrupted by SIGALRM. */
   if (sig == SIGALRM) return SLsignal_intr (sig, f);
# endif

   sigemptyset (&new_sa.sa_mask);
   new_sa.sa_handler = f;

   new_sa.sa_flags = 0;
# ifdef SA_RESTART
   new_sa.sa_flags |= SA_RESTART;
# endif

   if (-1 == sigaction (sig, &new_sa, &old_sa))
     return (SLSig_Fun_Type *) SIG_ERR;

   return old_sa.sa_handler;
#else
   /* Not POSIX. */
   return signal (sig, f);
#endif
}
Exemplo n.º 4
0
static int add_sigwinch_handlers (void)
{
#ifdef SIGWINCH
   (void) SLang_add_interrupt_hook (screen_size_changed_hook, NULL);
   (void) SLsignal_intr (SIGWINCH, sig_winch_handler);
#endif
   return 0;
}
Exemplo n.º 5
0
static void sigint_handler (int sig) {
  SLsignal_intr (SIGINT, sigint_handler);
  keyboard_quit = true;
#if SLANG_VERSION < 20000
  if (SLang_Ignore_User_Abort == 0) 
	  SLang_Error = USER_BREAK;
#endif
}
Exemplo n.º 6
0
static void default_sigint (int sig)
{
   sig = errno;			       /* use parameter */

   SLKeyBoard_Quit = 1;
   if (SLang_Ignore_User_Abort == 0) SLang_set_error (SL_USER_BREAK);
   SLsignal_intr (SIGINT, default_sigint);
   errno = sig;
}
Exemplo n.º 7
0
Arquivo: sig.c Projeto: hankem/jed
static void sigwinch_handler (int sig) /*{{{*/
{
   sig = errno;
   Jed_Resize_Pending = 1;
# ifdef SIGWINCH
   SLsignal_intr (SIGWINCH, sigwinch_handler);
# endif
   errno = sig;
}
Exemplo n.º 8
0
Arquivo: sig.c Projeto: hankem/jed
/* a control-G puts us here */
static void my_interrupt(int sig) /*{{{*/
{
   sig = errno;

   SLKeyBoard_Quit = 1;
   if (Ignore_User_Abort == 0) SLang_set_error (SL_USER_BREAK);
   SLsignal_intr (SIGINT, my_interrupt);

   errno = sig;
}
Exemplo n.º 9
0
int SLang_set_abort_signal (void (*hand)(int))
{
   int save_errno = errno;
   SLSig_Fun_Type *f;

   if (hand == NULL) hand = default_sigint;
   f = SLsignal_intr (SIGINT, hand);

   errno = save_errno;

   if (f == (SLSig_Fun_Type *) SIG_ERR)
     return -1;

   return 0;
}
Exemplo n.º 10
0
Arquivo: sig.c Projeto: hankem/jed
void init_signals (void) /*{{{*/
{
#if !defined(VMS) || (__VMS_VER >= 70000000)

#ifdef SIGWINCH
   (void) SLsignal_intr(SIGWINCH, sigwinch_handler);
#endif

   Old_Sigint_Handler = SLsignal_intr (SIGINT, my_interrupt);

   SLsignal (SIGHUP, sig_hup_exit_jed);
   SLsignal (SIGQUIT, sig_hup_exit_jed);
   SLsignal (SIGTERM, sig_hup_exit_jed);

   SLsignal (SIGILL, sig_exit_jed);
#if 0 && defined(SIGTRAP)
   SLsignal (SIGTRAP, sig_exit_jed);
#endif
#if 0
   SLsignal (SIGIOT, sig_exit_jed);  /* used by abort */
#endif
#ifdef SIGPIPE
   SLsignal_intr (SIGPIPE, SIG_IGN);
#endif
   /* SIGNAL (SIGFPE, sig_exit_jed); */
#ifdef SIGBUS
   SLsignal (SIGBUS, sig_exit_jed);
#endif
#if 0
   SLsignal (SIGSEGV, sig_exit_jed);
#endif
#ifdef SIGSYS
    SLsignal (SIGSYS, sig_exit_jed);
#endif

#ifdef SIGTSTP
   if (Jed_Handle_SIGTSTP)
     {
	Old_Sigtstp_Handler = SLsignal_intr (SIGTSTP, sig_sys_spawn_cmd);
	if (SIG_DFL != Old_Sigtstp_Handler)
	  Jed_Suspension_Not_Allowed = 1;
     }
#endif

#if CATCH_SIGTTIN
# ifdef SIGTTOU
   SLsignal_intr (SIGTTOU, background_read);
# endif
# ifdef SIGTTIN
   SLsignal_intr (SIGTTIN, background_read);
# endif
#endif

#endif /* VMS */
}
Exemplo n.º 11
0
static void signal_handler (int sig)
{
   Signal_Type *s;
   int e = errno;

   /* Until the signal has been delivered, block it. */
   /* Hmmm... it appears that the system unblocks the signal as soon
    * as this function exits.  Fortunately, this is not an issue.
    */
   /* (void) block_signal (sig); */
   (void) SLsignal_intr (sig, &signal_handler);

   s = find_signal (sig);	       /* cannot fail here */

   s->pending = 1;
   if (sig == SIGINT)
     SLKeyBoard_Quit = 1;
   _pSLang_signal_interrupt ();
   errno = e;
}
Exemplo n.º 12
0
static int set_old_handler (Signal_Type *s, SLang_Ref_Type *ref, void (*old_handler)(int))
{
   if (old_handler == (void (*)(int))SIG_ERR)
     {
	_pSLang_verror (0, "signal system call failed");
	return -1;
     }

   if (ref != NULL)
     {
	int ret;

	if (old_handler == signal_handler)
	  ret = SLang_assign_nametype_to_ref (ref, s->handler);
	else
	  {
	     int h;

	     if (old_handler == SIG_IGN)
	       h = SIG_IGN_CONSTANT;
	     else if (old_handler == SIG_DFL)
	       h = SIG_DFL_CONSTANT;
	     else
	       h = SIG_APP_CONSTANT;

	     ret = SLang_assign_to_ref (ref, SLANG_INT_TYPE, &h);
	  }
	if (ret == -1)
	  {
	     (void) SLsignal_intr (s->sig, old_handler);
	     return -1;
	  }
     }

   if (old_handler != signal_handler)
     s->c_handler = old_handler;

   return 0;
}
Exemplo n.º 13
0
/**
 * @brief Initialize the newt library
 * @return int - 0 for success, else < 0
 */
int newtInit(void) {
    char * MonoValue, * MonoEnv = "NEWT_MONO";
    const char *lang;
    int ret;

    if ((lang = getenv("LC_ALL")) == NULL)
        if ((lang = getenv("LC_CTYPE")) == NULL)
            if ((lang = getenv("LANG")) == NULL)
                lang = "";
    /* slang doesn't support multibyte encodings except UTF-8,
       avoid character corruption by redrawing the screen */
    if (strstr (lang, ".euc") != NULL)
	trashScreen = 1;

    (void) strlen(ident);

    SLutf8_enable(-1);
    SLtt_get_terminfo();
    SLtt_get_screen_size();

    MonoValue = getenv(MonoEnv);
    if ( MonoValue != NULL )
	SLtt_Use_Ansi_Colors = 0;

    if ((ret = SLsmg_init_smg()) < 0)
	return ret;
    if ((ret = SLang_init_tty(0, 0, 0)) < 0)
	return ret;

    initColors();
    newtCursorOff();
    initKeymap();

    SLsignal_intr(SIGWINCH, handleSigwinch);
    SLang_getkey_intr_hook = getkeyInterruptHook;

    return 0;
}
Exemplo n.º 14
0
int newtInit(void) {
    char * MonoValue, * MonoEnv = "NEWT_MONO", * lang;

    lang = getenv ("LANG");
    if (lang && !strcasecmp (lang, "ja_JP.eucJP"))
	trashScreen = 1;

    /* use the version variable just to be sure it gets included */
    strlen(version);

    SLtt_get_terminfo();
    SLtt_get_screen_size();

    MonoValue = getenv(MonoEnv);
    if ( MonoValue == NULL ) {
	SLtt_Use_Ansi_Colors = 1;
    } else {
	SLtt_Use_Ansi_Colors = 0;
    }

    SLsmg_init_smg();
    SLang_init_tty(0, 0, 0);

    newtSetColors(newtDefaultColorPalette);
    newtCursorOff();
    /*initKeymap();*/

    /*memset(&sa, 0, sizeof(sa));
    sa.sa_handler = handleSigwinch;
    sigaction(SIGWINCH, &sa, NULL);*/

    SLsignal_intr(SIGWINCH, handleSigwinch);
    SLang_getkey_intr_hook = getkeyInterruptHook;



    return 0;
}
Exemplo n.º 15
0
static void signal_intrinsic (void)
{
   SLang_Name_Type *f;
   Signal_Type *s;
   void (*old_handler) (int);
   SLang_Ref_Type *old_ref;

   if (SLang_Num_Function_Args == 3)
     {
	if (-1 == SLang_pop_ref (&old_ref))
	  return;
     }
   else old_ref = NULL;

   if (SLang_Num_Function_Args == 0)
     {
	SLang_verror (SL_Internal_Error, "signal called with 0 args");
	return;
     }

   if (SLANG_INT_TYPE == SLang_peek_at_stack ())
     {
	int h;

	if ((-1 == SLang_pop_int (&h))
	    || (-1 == pop_signal (&s)))
	  {
	     SLang_free_ref (old_ref);
	     return;
	  }

	/* If this signal has already been caught, deliver it now to the old handler */
	if (s->pending)
	  handle_signal (s);
	/* Note that the signal has the potential of being lost if the user has
	 * blocked its delivery.  For this reason, the unblock_signal intrinsic
	 * will have to deliver the signal via an explicit kill if it is pending.
	 */

	if (h == SIG_IGN_CONSTANT)
	  old_handler = SLsignal_intr (s->sig, SIG_IGN);
	else if (h == SIG_DFL_CONSTANT)
	  old_handler = SLsignal_intr (s->sig, SIG_DFL);
	else if (h == SIG_APP_CONSTANT)
	  old_handler = SLsignal_intr (s->sig, s->c_handler);
	else
	  {
	     SLang_free_ref (old_ref);
	     _pSLang_verror (SL_INVALID_PARM, "Signal handler '%d' is invalid", h);
	     return;
	  }

	if (-1 == set_old_handler (s, old_ref, old_handler))
	  {
	     SLang_free_ref (old_ref);
	     return;
	  }

	if (s->handler != NULL)
	  {
	     SLang_free_function (s->handler);
	     s->handler = NULL;
	  }

	SLang_free_ref (old_ref);
	return;
     }

   if (NULL == (f = SLang_pop_function ()))
     {
	SLang_free_ref (old_ref);
	return;
     }

   if (-1 == pop_signal (&s))
     {
	SLang_free_ref (old_ref);
	SLang_free_function (f);
	return;
     }

   old_handler = SLsignal_intr (s->sig, signal_handler);
   if (-1 == set_old_handler (s, old_ref, old_handler))
     {
	SLang_free_ref (old_ref);
	SLang_free_function (f);
	return;
     }

   if (s->handler != NULL)
     SLang_free_function (s->handler);
   s->handler = f;
   SLang_free_ref (old_ref);
}