Re: [PATCH] Reset the terminal state if we are killed by a fatal signal.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2008/4/8 Mike Frysinger <vapier@xxxxxxxxxx>:
>  if you're worried about portability, you should be using sigaction().
>  otherwise, use of signal() should really assume Linux semantics.

I could always redo the patch to use sigaction with SA_RESETHAND if
you prefer.

The call to signal is, I believe, necessary unless we use switch to
using sigaction :-

orbital:misc$ cat defsignal.c
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>


static void
say(const char *s)
{
  size_t n = strlen(s);
  write(1, s, n);
}

static void
handler(int sig)
{
  void (*oldhandler)(int);

  oldhandler = signal(sig, SIG_IGN);
  signal(sig, oldhandler);

  if (oldhandler == SIG_DFL)
    say("default\n");
  else if (oldhandler == SIG_IGN)
    say("ignored\n");
  else if (oldhandler == handler)
    say("unchanged\n");
  else
    say("something else\n");
}

int
main (int argc, char *argv[])
{
  signal(SIGINT, handler);
  kill(getpid(), SIGINT);
  return 0;
}
orbital:misc$ gcc -o defsignal  defsignal.c
orbital:misc$ ./defsignal
unchanged
orbital:misc$ uname -a
Linux orbital 2.6.24-1-686 #1 SMP Thu Mar 27 17:45:04 UTC 2008 i686 GNU/Linux
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux