Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 367015 | Differences between
and this patch

Collapse All | Expand All

(-)a/dtach.h (+2 lines)
Lines 124-129 struct packet Link Here
124
*/
124
*/
125
#define BUFSIZE 4096
125
#define BUFSIZE 4096
126
126
127
#define SCROLLSIZE 8192
128
127
/* This hopefully moves to the bottom of the screen */
129
/* This hopefully moves to the bottom of the screen */
128
#define EOS "\033[999H"
130
#define EOS "\033[999H"
129
131
(-)a/master.c (-1 / +68 lines)
Lines 54-59 static struct client *clients; Link Here
54
/* The pseudo-terminal created for the child process. */
54
/* The pseudo-terminal created for the child process. */
55
static struct pty the_pty;
55
static struct pty the_pty;
56
56
57
/* The scrollback buffer */
58
static unsigned char scrollback[SCROLLSIZE];
59
static int scroll_end, scroll_full;
60
57
#ifndef HAVE_FORKPTY
61
#ifndef HAVE_FORKPTY
58
pid_t forkpty(int *amaster, char *name, struct termios *termp,
62
pid_t forkpty(int *amaster, char *name, struct termios *termp,
59
	struct winsize *winp);
63
	struct winsize *winp);
Lines 214-219 create_socket(char *name) Link Here
214
	return s;
218
	return s;
215
}
219
}
216
220
221
/* Write the data in *buf into the scrollback buffer */
222
static void
223
write_scrollback(unsigned char *buf, int len)
224
{
225
	int n;
226
	if (len > SCROLLSIZE)
227
	{
228
		buf = buf + (len - SCROLLSIZE);
229
		len = SCROLLSIZE;
230
	}
231
232
	n = SCROLLSIZE - scroll_end;
233
	if (n >= len)
234
	{
235
		memcpy(scrollback + scroll_end, buf,
236
		       len * sizeof(unsigned char));
237
		scroll_end += len * sizeof(unsigned char);
238
		scroll_full = 1;
239
	}
240
	else
241
	{
242
		memcpy(scrollback + scroll_end, buf,
243
		       n * sizeof(unsigned char));
244
		scroll_end = len - n;
245
		memcpy(scrollback, buf,
246
		       scroll_end * sizeof(unsigned char));
247
	}
248
}
249
250
/* Send the data in the scrollback buffer to client */
251
static void
252
send_scrollback(struct client *p)
253
{
254
	int written, len;
255
	if (scroll_full)
256
	{
257
		len = SCROLLSIZE - scroll_end;
258
		written = 0;
259
		while (written < len)
260
		{
261
			int n = write(p->fd, scrollback + scroll_end + written,
262
			              len - written);
263
			if (n > 0)
264
				written += n;
265
			else if (n == 0 || errno != EINTR)
266
				break;
267
		}
268
	}
269
	len = scroll_end;
270
	written = 0;
271
	while (written < len)
272
	{
273
		int n = write(p->fd, scrollback + written, len - written);
274
		if (n > 0)
275
			written += n;
276
		else if (n == 0 || errno != EINTR)
277
			break;
278
	}
279
}
280
217
/* Process activity on the pty - Input and terminal changes are sent out to
281
/* Process activity on the pty - Input and terminal changes are sent out to
218
** the attached clients. If the pty goes away, we die. */
282
** the attached clients. If the pty goes away, we die. */
219
static void
283
static void
Lines 296-301 top: Link Here
296
	/* Try again if nothing happened. */
360
	/* Try again if nothing happened. */
297
	if (!FD_ISSET(s, &readfds) && nclients == 0)
361
	if (!FD_ISSET(s, &readfds) && nclients == 0)
298
		goto top;
362
		goto top;
363
364
        write_scrollback( buf, len );
299
}
365
}
300
366
301
/* Process activity on the control socket */
367
/* Process activity on the control socket */
Lines 324-329 control_activity(int s) Link Here
324
	if (p->next)
390
	if (p->next)
325
		p->next->pprev = &p->next;
391
		p->next->pprev = &p->next;
326
	*(p->pprev) = p;
392
	*(p->pprev) = p;
393
394
        send_scrollback( p );
327
}
395
}
328
396
329
/* Process activity from a client. */
397
/* Process activity from a client. */
330
- 

Return to bug 367015