Beispiel #1
0
void	sig_handler(int sig)
{
  t_sh	*shell;

  shell = get_sh_info(NULL);
  SETFLAG(shell->signal, FLAGPOS(sig));
  if (sig == SIGINT)
    {
      my_putstr("\n", 1, -1);
      my_putstr(shell->param.str_prompt, 1, -1);
      if (shell->param.fallback == 1)
        {
          if (shell->param.cmd != NULL)
            shell->param.cmd[0] = '\0';
          shell->param.pos = 0;
          refresh_view(&(shell->param));
          view(shell->param.cmd, &(shell->param));
        }
    }
  if (sig == SIGWINCH && shell->param.fallback == 1)
    clear_cmd(shell->param.cmd, &(shell->param));
  if ((sig == SIGHUP) || (sig == SIGTERM) || (sig == SIGQUIT))
    {
      SETFLAG(shell->beepbeepexit, FLAGPOS(EXIT_F_POS));
      close(0);
    }
  init_sig(&sig_handler);
}
Beispiel #2
0
/*!
 * \brief DialogSettings::DialogSettings
 * \param parent
 *
 * DialogSettings
 */
DialogSettings::DialogSettings(QWidget *parent) :
    QDialog(parent)
{
    if (DEBUG) cout << Q_FUNC_INFO << endl;

    init_var();
    init_win();
    init_sig();
    init_css();

    init_settings();
}
Beispiel #3
0
int luaopen_myreadline(lua_State *L)
{
    luaL_newlib(L, lib);
    storedL = L;

    rl_basic_word_break_characters = " \t\n\"\\'><;:%~!@#$%^&*()-+={}[].,";
    rl_attempted_completion_function = do_completion;

    set_history_file();
    init_sig();

    return 1;
}
Beispiel #4
0
int
main(int argc, char *argv[])
{
	int sd;
	ssize_t len;
	socklen_t slen;
	char buf[1024];
	struct sockaddr_in6 sa;

	if (init_sig(argc, argv) != 0) {
		exit(1);
	}

	sd = init_server(argc, argv);
	if (sd == -1) {
		exit(1);
	}

	for ( ; ; ) {
		//printf("-> ");
		//fflush(stdout);
		slen = sizeof (sa);
		len = recvfrom(sd, buf, sizeof (buf), 0, (struct sockaddr *)&sa, &slen);
		if (len != -1) {
#if 0
			char name[128];
			char serv_name[64];
			getnameinfo((struct sockaddr *)&sa, slen,
				name, sizeof(name), serv_name, sizeof(serv_name),
				NI_NUMERICHOST | NI_NUMERICSERV);
			printf("recved %ld bytes from %s/%s.\n", (long)len, name, serv_name);
#endif //0
			sendto(sd, buf, len, 0, (struct sockaddr *)&sa, slen);
		}
		else {
			if (errno == EINTR) {
				continue;
			}
			perror("recvfrom");
			break;
		}
	}

	close(sd);

	return 0;
}
/*---------------------------------------------------------------------+
|                               main ()                                |
| ==================================================================== |
|                                                                      |
| Function:  Main program  (see prolog for more details)               |
|                                                                      |
+---------------------------------------------------------------------*/
int main (int argc, char **argv)
{
	int	timeout = MAXTIME*60;	/* Timeout value */
	int	i;			/* Loop index */
	char 	msg [256];		/* Buffer for error message */

	/* Print out program header */
	printf ("%s: IPC TestSuite program\n\n", *argv);
	fflush (stdout);

	/* Set up our signal handler */
	init_sig ();

	/*
	 * Send MAXSIG signals to the process
	 *
	 * Using raise, send MAX signals to the process.  Then loop until
	 * every signal is caught by the signal handler (or the timer expires).
	 */
	printf ("\tSend MAX (%d) signals to the process...\n", MAXSIG);
	fflush (stdout);
	for (i=0; i<MAXSIG; i++)
		raise (SIGUSR1);

	while (signals_received < MAXSIG && --timeout)
		sleep (1);

	if (timeout == 0) {
		sprintf (msg, "failed to received %d signals in %d minutes\n",
			MAXSIG, MAXTIME);
		error (msg, __LINE__);
	}

	/*
	 * Received ALL of the sent signals!  Exit with success
	 */
	printf ("\n\tReceived EVERY signal!\n");

	printf ("\nsuccessful!\n");
	return (0);
}
DialogFlowConstructorEPI::DialogFlowConstructorEPI(Coord **coords_arterial, Coord **coords_venous, Coord **coords_csf,
                                             QStringList *list_arterial, QStringList *list_venous, QStringList *list_csf,
                                             Coord *coord_arterial_cervical, Coord *coord_venous_cervical, Coord *coord_csf_cervical,
                                             QStringList *list_arterial_cervical, QStringList *list_venous_cervical, QStringList *list_csf_cervical,
                                             Coord *coord_arterial_cerebral, Coord *coord_venous_cerebral, Coord *coord_csf_cerebral,
                                             QStringList *list_arterial_cerebral, QStringList *list_venous_cerebral, QStringList *list_csf_cerebral,
                                             QWidget *parent) :
    QDialog(parent)
{
    if (DEBUG) cout << Q_FUNC_INFO << endl;

    //Address copy
    this->coords_arterial = coords_arterial;
    this->coords_venous = coords_venous;
    this->coords_csf = coords_csf;

    this->coord_arterial_cervical = coord_arterial_cervical;
    this->coord_venous_cervical = coord_venous_cervical;
    this->coord_csf_cervical = coord_csf_cervical;
    this->coord_arterial_cerebral = coord_arterial_cerebral;
    this->coord_venous_cerebral = coord_venous_cerebral;
    this->coord_csf_cerebral = coord_csf_cerebral;

    this->list_arterial = list_arterial;
    this->list_venous = list_venous;
    this->list_csf = list_csf;

    this->list_arterial_cervical = list_arterial_cervical;
    this->list_venous_cervical = list_venous_cervical;
    this->list_csf_cervical = list_csf_cervical;

    this->list_arterial_cerebral = list_arterial_cerebral;
    this->list_venous_cerebral = list_venous_cerebral;
    this->list_csf_cerebral = list_csf_cerebral;

    init_var();
    init_win();
    init_sig();
    init_css();
}
Beispiel #7
0
void
init(
	int		argc,
	char		**argv)
{
	xfs_sb_t	*sbp;
	void		*bufp = NULL;
	int		c;

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);

	progname = basename(argv[0]);
	while ((c = getopt(argc, argv, "c:fFip:rxVl:")) != EOF) {
		switch (c) {
		case 'c':
			cmdline = xrealloc(cmdline, (ncmdline+1)*sizeof(char*));
			cmdline[ncmdline++] = optarg;
			break;
		case 'f':
			x.disfile = 1;
			break;
		case 'F':
			force = 1;
			break;
		case 'i':
			x.isreadonly = (LIBXFS_ISREADONLY|LIBXFS_ISINACTIVE);
			break;
		case 'p':
			progname = optarg;
			break;
		case 'r':
			x.isreadonly = LIBXFS_ISREADONLY;
			break;
		case 'l':
			x.logname = optarg;
			break;
		case 'x':
			expert_mode = 1;
			break;
		case 'V':
			printf(_("%s version %s\n"), progname, VERSION);
			exit(0);
		case '?':
			usage();
			/*NOTREACHED*/
		}
	}
	if (optind + 1 != argc) {
		usage();
		/*NOTREACHED*/
	}

	fsdevice = argv[optind];
	if (!x.disfile)
		x.volname = fsdevice;
	else
		x.dname = fsdevice;

	if (!libxfs_init(&x)) {
		fputs(_("\nfatal error -- couldn't initialize XFS library\n"),
			stderr);
		exit(1);
	}

	if (read_bbs(XFS_SB_DADDR, 1, &bufp, NULL)) {
		fprintf(stderr, _("%s: %s is invalid (cannot read first 512 "
			"bytes)\n"), progname, fsdevice);
		exit(1);
	}

	/* copy SB from buffer to in-core, converting architecture as we go */
	libxfs_sb_from_disk(&xmount.m_sb, bufp);
	xfree(bufp);

	sbp = &xmount.m_sb;
	if (sbp->sb_magicnum != XFS_SB_MAGIC) {
		fprintf(stderr, _("%s: %s is not a valid XFS filesystem (unexpected SB magic number 0x%08x)\n"),
			progname, fsdevice, sbp->sb_magicnum);
		if (!force)
			exit(EXIT_FAILURE);
	}

	mp = libxfs_mount(&xmount, sbp, x.ddev, x.logdev, x.rtdev,
				LIBXFS_MOUNT_ROOTINOS | LIBXFS_MOUNT_DEBUGGER);
	if (!mp) {
		mp = libxfs_mount(&xmount, sbp, x.ddev, x.logdev, x.rtdev,
				LIBXFS_MOUNT_DEBUGGER);
		if (!mp) {
			fprintf(stderr, _("%s: device %s unusable (not an XFS "
				"filesystem?)\n"), progname, fsdevice);
			exit(1);
		}
	}
	blkbb = 1 << mp->m_blkbb_log;

	push_cur();
	init_commands();
	init_sig();
}
Beispiel #8
0
/*---------------------------------------------------------------------+
|                               main ()                                |
| ==================================================================== |
|                                                                      |
| Function:  Main program  (see prolog for more details)               |
|                                                                      |
+---------------------------------------------------------------------*/
int main (int argc, char **argv)
{
	sigset_t	setsig, 		/* Initial signal mask */
			newsetsig;		/* Second signal mask */
	pid_t		pid = getpid ();	/* Process ID (of this process) */

	/* Print out program header */
	printf ("%s: IPC TestSuite program\n\n", *argv);

	/*
	 * Establish signal handler for each signal & reset "valid signals"
	 * array
	 */
	init_sig ();
	reset_valid_sig ();

	sigemptyset(&setsig);
	if (sigprocmask (SIG_SETMASK, &setsig, (sigset_t *) NULL) < 0)
		sys_error ("sigprocmask failed", __LINE__);

	/*
	 * Send SIGILL, SIGALRM & SIGIOT signals to this process:
	 *
	 * First indicate which signals the signal handler should expect
	 * by setting the corresponding valid_sig[] array fields.
	 *
	 * Then send the signals to this process.
	 *
	 * And finally verify that the signals were caught by the signal
	 * handler by checking to see if the corresponding valid_sig[] array
	 * fields were reset.
	 */
	printf ("\tSend SIGILL, SIGALRM, SIGIOT signals to process\n");
	valid_sig [SIGILL] = 1;
	valid_sig [SIGALRM] = 1;
	valid_sig [SIGIOT] = 1;

	kill (pid, SIGILL);
	kill (pid, SIGALRM);
	kill (pid, SIGIOT);

	if (valid_sig [SIGILL])
		error ("failed to receive SIGILL signal!", __LINE__);
	if (valid_sig [SIGALRM])
		error ("failed to receive SIGALRM signal!", __LINE__);
	if (valid_sig [SIGIOT])
		error ("failed to receive SIGIOT signal!", __LINE__);

	/*
	 * Block SIGILL, SIGALRM & SIGIOT signals:
	 *
	 * First initialize the signal set so that all signals are excluded,
	 * then individually add the signals to block to the signal set.
	 *
	 * Then change the process signal mask with sigprocmask (SIG_SETMASK).
	 *
	 * Verify that the desired signals are blocked from interrupting the
	 * process, by sending both blocked and unblocked signals to the
	 * process.  Only the unblocked signals should interrupt the process.
	 */
	printf ("\n\tBlock SIGILL, SIGALRM, SIGIOT signals, " \
		"and resend signals + others\n");
	sigemptyset(&setsig);

	if (sigaddset (&setsig, SIGIOT) < 0)
		sys_error ("sigaddset (SIGIOT) failed", __LINE__);
	if (sigaddset (&setsig, SIGILL) < 0)
		sys_error ("sigaddset (SIGILL) failed", __LINE__);
	if (sigaddset (&setsig, SIGALRM) < 0)
		sys_error ("sigaddset (SIGALRM) failed", __LINE__);

	if (sigprocmask (SIG_SETMASK, &setsig, (sigset_t *) NULL) < 0)
		sys_error ("sigaddset (SIGALRM) failed", __LINE__);

	valid_sig [SIGFPE] = 1;
	valid_sig [SIGTERM] = 1;
	valid_sig [SIGINT] = 1;

	kill (pid, SIGILL);
	kill (pid, SIGALRM);
	kill (pid, SIGIOT);
	kill (pid, SIGFPE);
	kill (pid, SIGTERM);
	kill (pid, SIGINT);

	if (valid_sig [SIGFPE])
		sys_error ("failed to receive SIGFPE signal!", __LINE__);
	if (valid_sig [SIGTERM])
		sys_error ("failed to receive SIGTERM signal!", __LINE__);
	if (valid_sig [SIGINT])
		sys_error ("failed to receive SIGINT signal!", __LINE__);

	/*
	 * Block additional SIGFPE, SIGTERM & SIGINT signals:
	 *
	 * Create an other signal set to contain the additional signals to block
	 * and add the signals to block to the signal set.
	 *
	 * Change the process signal mask to block the additional signals
	 * with the sigprocmask (SIG_BLOCK) function.
	 *
	 * Verify that all of the desired signals are now blocked from
	 * interrupting the process.  None of the specified signals should
	 * interrupt the process until the process signal mask is changed.
	 */
	printf ("\n\tBlock rest of signals\n");
	sigemptyset (&newsetsig);

	sigaddset (&newsetsig, SIGFPE);
	sigaddset (&newsetsig, SIGTERM);
	sigaddset (&newsetsig, SIGINT);

	if (sigprocmask (SIG_BLOCK, &newsetsig, &setsig) < 0)
		sys_error ("sigprocmask failed", __LINE__);

	kill (pid, SIGILL);
	kill (pid, SIGALRM);
	kill (pid, SIGIOT);
	kill (pid, SIGFPE);
	kill (pid, SIGTERM);
	kill (pid, SIGINT);

	/*
	 * Wait two seconds just to make sure that none of the specified
	 * signals interrupt the process (They should all be blocked).
	 */
	sleep (2);

	/*
	 * Change the process signal mask:
	 *
	 * Now specifiy a new process signal set to allow the SIGINT signal
	 * to interrupt the process.  Create the signal set by initializing
	 * the signal set with sigfillset () so that all signals are included
	 * in the signal set, then remove the SIGINT signal from the set with
	 * sigdelset ().
	 *
	 * Force the  process to suspend execution until delivery of an
	 * unblocked signal (SIGINT in this case) with sigsuspend ().
	 *
	 * Additionally, verify that the SIGINT signal was received.
	 */
	valid_sig [SIGINT] = 1;

	printf ("\n\tChange signal mask & wait until signal interrupts process\n");
	if (sigfillset (&setsig) < 0)
		sys_error ("sigfillset failed", __LINE__);
	if (sigdelset (&setsig, SIGINT) < 0)
		sys_error ("sigdelset failed", __LINE__);
	if (sigsuspend(&setsig) != -1 || errno != 4)
		sys_error ("sigsuspend failed", __LINE__);

	if (valid_sig [SIGINT])
		error ("failed to receive SIGIOT signal!", __LINE__);

	/* Program completed successfully -- exit */
	printf ("\nsuccessful!\n");

	return (0);
}
Beispiel #9
0
void init_introspect(void)
{
	init_sig();
}
Beispiel #10
0
static int
signame_init (void)
{
  int i;

  undoc = xstrdup (_("unknown signal"));

  /* Initialize signal names.  */
  for (i = 0; i < NSIG; i++)
    sys_siglist[i] = undoc;

  /* Initialize signal names.  */
#if defined (SIGHUP)
  init_sig (SIGHUP, "HUP", _("Hangup"));
#endif
#if defined (SIGINT)
  init_sig (SIGINT, "INT", _("Interrupt"));
#endif
#if defined (SIGQUIT)
  init_sig (SIGQUIT, "QUIT", _("Quit"));
#endif
#if defined (SIGILL)
  init_sig (SIGILL, "ILL", _("Illegal Instruction"));
#endif
#if defined (SIGTRAP)
  init_sig (SIGTRAP, "TRAP", _("Trace/breakpoint trap"));
#endif
  /* If SIGIOT == SIGABRT, we want to print it as SIGABRT because
     SIGABRT is in ANSI and POSIX.1 and SIGIOT isn't.  */
#if defined (SIGABRT)
  init_sig (SIGABRT, "ABRT", _("Aborted"));
#endif
#if defined (SIGIOT)
  init_sig (SIGIOT, "IOT", _("IOT trap"));
#endif
#if defined (SIGEMT)
  init_sig (SIGEMT, "EMT", _("EMT trap"));
#endif
#if defined (SIGFPE)
  init_sig (SIGFPE, "FPE", _("Floating point exception"));
#endif
#if defined (SIGKILL)
  init_sig (SIGKILL, "KILL", _("Killed"));
#endif
#if defined (SIGBUS)
  init_sig (SIGBUS, "BUS", _("Bus error"));
#endif
#if defined (SIGSEGV)
  init_sig (SIGSEGV, "SEGV", _("Segmentation fault"));
#endif
#if defined (SIGSYS)
  init_sig (SIGSYS, "SYS", _("Bad system call"));
#endif
#if defined (SIGPIPE)
  init_sig (SIGPIPE, "PIPE", _("Broken pipe"));
#endif
#if defined (SIGALRM)
  init_sig (SIGALRM, "ALRM", _("Alarm clock"));
#endif
#if defined (SIGTERM)
  init_sig (SIGTERM, "TERM", _("Terminated"));
#endif
#if defined (SIGUSR1)
  init_sig (SIGUSR1, "USR1", _("User defined signal 1"));
#endif
#if defined (SIGUSR2)
  init_sig (SIGUSR2, "USR2", _("User defined signal 2"));
#endif
  /* If SIGCLD == SIGCHLD, we want to print it as SIGCHLD because that
     is what is in POSIX.1.  */
#if defined (SIGCHLD)
  init_sig (SIGCHLD, "CHLD", _("Child exited"));
#endif
#if defined (SIGCLD)
  init_sig (SIGCLD, "CLD", _("Child exited"));
#endif
#if defined (SIGPWR)
  init_sig (SIGPWR, "PWR", _("Power failure"));
#endif
#if defined (SIGTSTP)
  init_sig (SIGTSTP, "TSTP", _("Stopped"));
#endif
#if defined (SIGTTIN)
  init_sig (SIGTTIN, "TTIN", _("Stopped (tty input)"));
#endif
#if defined (SIGTTOU)
  init_sig (SIGTTOU, "TTOU", _("Stopped (tty output)"));
#endif
#if defined (SIGSTOP)
  init_sig (SIGSTOP, "STOP", _("Stopped (signal)"));
#endif
#if defined (SIGXCPU)
  init_sig (SIGXCPU, "XCPU", _("CPU time limit exceeded"));
#endif
#if defined (SIGXFSZ)
  init_sig (SIGXFSZ, "XFSZ", _("File size limit exceeded"));
#endif
#if defined (SIGVTALRM)
  init_sig (SIGVTALRM, "VTALRM", _("Virtual timer expired"));
#endif
#if defined (SIGPROF)
  init_sig (SIGPROF, "PROF", _("Profiling timer expired"));
#endif
#if defined (SIGWINCH)
  /* "Window size changed" might be more accurate, but even if that
     is all that it means now, perhaps in the future it will be
     extended to cover other kinds of window changes.  */
  init_sig (SIGWINCH, "WINCH", _("Window changed"));
#endif
#if defined (SIGCONT)
  init_sig (SIGCONT, "CONT", _("Continued"));
#endif
#if defined (SIGURG)
  init_sig (SIGURG, "URG", _("Urgent I/O condition"));
#endif
#if defined (SIGIO)
  /* "I/O pending" has also been suggested.  A disadvantage is that signal
     only happens when the process has asked for it, not every time I/O is
     pending.  Another disadvantage is the confusion from giving it a
     different name than under Unix.  */
  init_sig (SIGIO, "IO", _("I/O possible"));
#endif
#if defined (SIGWIND)
  init_sig (SIGWIND, "WIND", _("SIGWIND"));
#endif
#if defined (SIGPHONE)
  init_sig (SIGPHONE, "PHONE", _("SIGPHONE"));
#endif
#if defined (SIGPOLL)
  init_sig (SIGPOLL, "POLL", _("I/O possible"));
#endif
#if defined (SIGLOST)
  init_sig (SIGLOST, "LOST", _("Resource lost"));
#endif
#if defined (SIGDANGER)
  init_sig (SIGDANGER, "DANGER", _("Danger signal"));
#endif
#if defined (SIGINFO)
  init_sig (SIGINFO, "INFO", _("Information request"));
#endif
#if defined (SIGNOFP)
  init_sig (SIGNOFP, "NOFP", _("Floating point co-processor not available"));
#endif

  return 1;
}
Beispiel #11
0
/*---------------------------------------------------------------------+
|                               main ()                                |
| ==================================================================== |
|                                                                      |
| Function:  Main program  (see prolog for more details)               |
|                                                                      |
+---------------------------------------------------------------------*/
int main(int argc, char **argv)
{
	sigset_t newmask,	/* New signal mask */
	 oldmask,		/* Initial signal mask */
	 pendmask;		/* Pending signal mask */
	int i;			/* Loop index */

	/* Print out program header */
	printf("%s: IPC TestSuite program\n\n", *argv);

	/* Set up our signal handler */
	init_sig();

	/*
	 * Block ALL signals from interrupting the process
	 */
	printf("\tBlock all signals from interrupting the process\n");
	if (sigfillset(&newmask) < 0)
		error("sigfillset failed", __LINE__);
	if (sigprocmask(SIG_SETMASK, &newmask, &oldmask) < 0)
		error("sigprocmask failed", __LINE__);

	/*
	 * Send MAXSIG signals to the current process -- since ALL of the
	 * signals are blocked, none of the signals should interrupt the
	 * process
	 */
	printf("\n\tSend MAX (%d) SIGUSR1 signals to the process...\n", MAXSIG);
	for (i = 0; i < MAXSIG; i++)
		raise(SIGUSR1);

	/*
	 *  Sleep for a short time and the check to ensure that a SIGUSR1
	 *  signal is pending
	 */
	sleep(2);

	printf("\n\tEnsure at least one SIGUSR1 signal is pending\n");
	if (sigpending(&pendmask) < 0)
		error("sigpending failed", __LINE__);

	if (sigismember(&pendmask, SIGUSR1) == 0)
		error("sent multiple SIGUSR1 signals to process, "
		      "yet none are pending!", __LINE__);

	/*
	 * Change the signal mask to allow signals to interrupt the process
	 * and then suspend execution until a signal reaches the process
	 *
	 * Then verify that at least one signal was received
	 */
	printf("\n\tChange signal mask & wait for SIGUSR1 signal\n");
	if (sigsuspend(&oldmask) != -1 || errno != 4)
		error("sigsuspend failed", __LINE__);

	if (signals_received != 1) {
		printf("Signals are queued!  Sent %d signals, "
		       "while %d were queued\n", MAXSIG, signals_received);
	}

	/* Program completed successfully -- exit */
	printf("\nsuccessful!\n");
	return (0);
}