void shell_pid_cb(void *opaque, int status) { ShellState *s = opaque; EditBuffer *b = s->b; QEmacsState *qs = s->qe_state; EditState *e; char buf[1024]; if (s->is_shell) { snprintf(buf, sizeof(buf), "\nProcess shell finished\n"); } else { time_t ti; char *time_str; ti = time(NULL); time_str = ctime(&ti); if (WIFEXITED(status)) status = WEXITSTATUS(status); else status = -1; if (status == 0) { snprintf(buf, sizeof(buf), "\nCompilation finished at %s", time_str); } else { snprintf(buf, sizeof(buf), "\nCompilation exited abnormally with code %d at %s", status, time_str); } } eb_write(b, b->total_size, buf, strlen(buf)); set_pid_handler(s->pid, NULL, NULL); s->pid = -1; /* no need to leave the pty opened */ if (s->pty_fd >= 0) { set_read_handler(s->pty_fd, NULL, NULL); close(s->pty_fd); s->pty_fd = -1; } /* remove shell input mode */ s->grab_keys = 0; qe_ungrab_keys(); for (e = qs->first_window; e != NULL; e = e->next_window) { if (e->b == b) e->interactive = 0; } edit_display(qs); dpy_flush(qs->screen); }
/* called when characters are available on the tty */ static void shell_read_cb(void *opaque) { ShellState *s = opaque; unsigned char buf[1024]; int len, i; len = read(s->pty_fd, buf, sizeof(buf)); if (len <= 0) return; for(i=0;i<len;i++) tty_emulate(s, buf[i]); /* now we do some refresh */ edit_display(&qe_state); dpy_flush(qe_state.screen); }
/* called when characters are available on the tty */ static void shell_read_cb(void *opaque) { ShellState *s = opaque; QEmacsState *qs = s->qe_state; unsigned char buf[1024]; int len, i; len = read(s->pty_fd, buf, sizeof(buf)); if (len <= 0) return; if (trace_buffer) eb_write(trace_buffer, trace_buffer->total_size, buf, len); for (i = 0; i < len; i++) tty_emulate(s, buf[i]); /* now we do some refresh */ edit_display(qs); dpy_flush(qs->screen); }