Diff

Differences From Artifact [b42e718b24]:

To Artifact [e17ee8f7dc]:


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
static int pty_signal_pipe[2] = { -1, -1 };   /* obviously bogus initial val */

struct pty_tag {
    Config cfg;
    int master_fd, slave_fd;
    void *frontend;
    char name[FILENAME_MAX];
    int child_pid;
    int term_width, term_height;
    int child_dead, finished;
    int exit_code;
    bufchain output_data;
};

/*







|







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
static int pty_signal_pipe[2] = { -1, -1 };   /* obviously bogus initial val */

struct pty_tag {
    Config cfg;
    int master_fd, slave_fd;
    void *frontend;
    char name[FILENAME_MAX];
    pid_t child_pid;
    int term_width, term_height;
    int child_dead, finished;
    int exit_code;
    bufchain output_data;
};

/*
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
    else if (a->child_pid > b->child_pid)
	return +1;
    return 0;
}

static int pty_find_by_pid(void *av, void *bv)
{
    int a = *(int *)av;
    Pty b = (Pty)bv;

    if (a < b->child_pid)
	return -1;
    else if (a > b->child_pid)
	return +1;
    return 0;







|







133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
    else if (a->child_pid > b->child_pid)
	return +1;
    return 0;
}

static int pty_find_by_pid(void *av, void *bv)
{
    pid_t a = *(pid_t *)av;
    Pty b = (Pty)bv;

    if (a < b->child_pid)
	return -1;
    else if (a > b->child_pid)
	return +1;
    return 0;
163
164
165
166
167
168
169

170
171
172
173
174
175
176
177
 * Likewise, since utmp is only used via pty_pre_init, it too must
 * be single-instance, so we can declare utmp-related variables
 * here.
 */
static Pty single_pty = NULL;

#ifndef OMIT_UTMP

static int pty_utmp_helper_pid, pty_utmp_helper_pipe;
static int pty_stamped_utmp;
static struct utmpx utmp_entry;
#endif

/*
 * pty_argv is a grievous hack to allow a proper argv to be passed
 * through from the Unix command line. Again, it doesn't really







>
|







163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
 * Likewise, since utmp is only used via pty_pre_init, it too must
 * be single-instance, so we can declare utmp-related variables
 * here.
 */
static Pty single_pty = NULL;

#ifndef OMIT_UTMP
static pid_t pty_utmp_helper_pid;
static int pty_utmp_helper_pipe;
static int pty_stamped_utmp;
static struct utmpx utmp_entry;
#endif

/*
 * pty_argv is a grievous hack to allow a proper argv to be passed
 * through from the Unix command line. Again, it doesn't really
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
int pty_select_result(int fd, int event)
{
    int ret = TRUE;
    Pty pty;

    if (fd == pty_signal_pipe[0]) {
	pid_t pid;
	int ipid;
	int status;
	char c[1];

	if (read(pty_signal_pipe[0], c, 1) <= 0)
	    /* ignore error */;
	/* ignore its value; it'll be `x' */

	do {
	    pid = waitpid(-1, &status, WNOHANG);

	    ipid = pid;
	    pty = find234(ptys_by_pid, &pid, pty_find_by_pid);

	    if (pty)
		ret = ret && pty_real_select_result(pty, -1, status);
	} while (pid > 0);
    } else {
	pty = find234(ptys_by_fd, &fd, pty_find_by_fd);







<










<







627
628
629
630
631
632
633

634
635
636
637
638
639
640
641
642
643

644
645
646
647
648
649
650
int pty_select_result(int fd, int event)
{
    int ret = TRUE;
    Pty pty;

    if (fd == pty_signal_pipe[0]) {
	pid_t pid;

	int status;
	char c[1];

	if (read(pty_signal_pipe[0], c, 1) <= 0)
	    /* ignore error */;
	/* ignore its value; it'll be `x' */

	do {
	    pid = waitpid(-1, &status, WNOHANG);


	    pty = find234(ptys_by_pid, &pid, pty_find_by_pid);

	    if (pty)
		ret = ret && pty_real_select_result(pty, -1, status);
	} while (pid > 0);
    } else {
	pty = find234(ptys_by_fd, &fd, pty_find_by_fd);