Exemplo n.º 1
0
void handle_eof(RP rp, TTY tp, char far* bp)
{
	ULONG state = tp->state;

	/* seen EOF */
	if (state & ST_EOF) {
		/* send a signal? */
		if (ISSET(state,ST_EOFSIGB))
			sendsig(SIGBREAK);
		else if(ISSET(state,ST_EOFSIGC))
			sendsig(SIGINT);

		/* what to return? */
		if (ISSET(state,ST_EOFCTLD))
		{
			bp[0] = CTRL('d');
			RWCNT(rp) = 1;
		}
		else if (ISSET(state,ST_EOFCTLC))
		{
			bp[0] = CTRL('c');
			RWCNT(rp) = 1;
		}
		else if (ISSET(state,ST_EOFCTLZ))
		{
			bp[0] = CTRL('z');
			RWCNT(rp) = 1;
		}
		else
		{
			RWCNT(rp) = 0;
		}
	}
}
Exemplo n.º 2
0
/*
 * Send a signal to one process.
 */
static int
kill_one(pid_t pid, int sig)
{
	struct proc *p;

	DPRINTF(("proc: killone pid=%d sig=%d\n", pid, sig));

	if ((p = p_find(pid)) == NULL)
		return ESRCH;
	return sendsig(p, sig);
}
Exemplo n.º 3
0
/*
 * This tty interrupt routine checks to see if the uart receiver
 * actually caused the interrupt.  If so it adds the character to
 * the tty input queue, echoing and processing backspace and carriage
 * return.  If the queue contains a full line, it wakes up anything
 * waiting on it.  If it is totally full, it beeps at the user.
 */
int
tty_int(void)
{
	char c;
	int found;
	char oc;

	found = 0;
again:
	if ((in(0x72) & 0x81) != 0x81)
		return (found);
	c = (in(0x73) & 0x7f);

	if (c == 0x1a)			/* ^Z */
		idump();		/* For debugging. */

	if (c == '\003')		/* ^C */
		sendsig(NULL, SIGINT);
	else if (c == '\017')		/* ^O */
		flshflag = !flshflag;
	else if (c == '\023')		/* ^S */
		stopflag = 1;
	else if (c == '\021') {		/* ^Q */
		stopflag = 0;
		wakeup(&stopflag);
	} else if (c == '\b') {
		if (uninsq(&ttyinq, &oc)) {
			if (oc == '\n') {
				/* Don't erase past newline. */
				insq(&ttyinq, oc);
			} else {
				_putc('\b');
				_putc(' ');
				_putc('\b');
			}
		}
	} else {
		if ((c == '\r') || (c == '\n')) {
			c = '\n';
			_putc('\r');
		}

		if (insq(&ttyinq, c))
			_putc(c);
		else
			_putc('\007');	/* Beep if no more room. */
	}

	if ((c == '\n') || (c == '\004'))	/* ^D */
		wakeup(&ttyinq);

	found = 1;
	goto again;	/* Loop until the uart has no data ready. */
}
Exemplo n.º 4
0
/*
 * Send a signal to all process in the process group.
 */
int
kill_pg(pid_t pgid, int sig)
{
	struct proc *p;
	struct pgrp *pgrp;
	list_t head, n;
	int error = 0;

	DPRINTF(("proc: killpg pgid=%d sig=%d\n", pgid, sig));

	if ((pgrp = pg_find(pgid)) == NULL)
		return ESRCH;

	head = &pgrp->pg_members;
	for (n = list_first(head); n != head; n = list_next(n)) {
		p = list_entry(n, struct proc, p_pgrp_link);
		if ((error = sendsig(p, sig)) != 0)
			break;
	}
	return error;
}
Exemplo n.º 5
0
int
main(int argc, char **argv)
{
    int	i = 0;

    progname = basename(argv[0]);
    if (argc >= 2 && argv[1][0] == '-') {
        i++;
        if (argv[1][1] == 's') {
            if (argv[1][2])
                sflag = getsig(&argv[1][2]);
            else if (argc >= 3) {
                i++;
                sflag = getsig(&argv[2][0]);
            } else
                usage();
        } else if (argv[1][1] == 'l')
            lflag = 1;
        else
            sflag = getsig(&argv[1][1]);
    }
    argv += i;
    argc -= i;
    if (lflag) {
        if (argc == 1)
            listsigs();
        else if (argc == 2)
            printsig(argv[1]);
        else
            usage();
    } else {
        if (argc <= 1)
            usage();
        for (i = 1; i < argc; i++)
            sendsig(argv[i]);
    }
    return status;
}