View | Details | Raw Unified | Return to bug 248377 | Differences between
and this patch

Collapse All | Expand All

(-)script.c (+33 lines)
Lines 428-433 Link Here
428
} while (0/*CONSTCOND*/)
428
} while (0/*CONSTCOND*/)
429
429
430
static void
430
static void
431
termset(void)
432
{
433
	struct termios traw;
434
435
	ttyflg = isatty(STDOUT_FILENO);
436
	if (!ttyflg)
437
		return;
438
439
	if (tcgetattr(STDOUT_FILENO, &tt) == -1)
440
		err(1, "tcgetattr");
441
442
	traw = tt;
443
	cfmakeraw(&traw);
444
	traw.c_lflag |= ISIG;
445
	if (tcsetattr(STDOUT_FILENO, TCSANOW, &traw) == -1)
446
		err(1, "tcsetattr");
447
}
448
449
static void
450
termreset(void)
451
{
452
	if (ttyflg)
453
		tcsetattr(STDOUT_FILENO, TCSADRAIN, &tt);
454
455
	ttyflg = 0;
456
}
457
458
static void
431
playback(FILE *fp)
459
playback(FILE *fp)
432
{
460
{
433
	struct timespec tsi, tso;
461
	struct timespec tsi, tso;
Lines 439-444 Link Here
439
	time_t tclock;
467
	time_t tclock;
440
	int reg;
468
	int reg;
441
469
470
	ttyflg = 0;
471
442
	if (fstat(fileno(fp), &pst) == -1)
472
	if (fstat(fileno(fp), &pst) == -1)
443
		err(1, "fstat failed");
473
		err(1, "fstat failed");
444
474
Lines 470-477 Link Here
470
				ctime(&tclock));
500
				ctime(&tclock));
471
			tsi = tso;
501
			tsi = tso;
472
			(void)consume(fp, stamp.scr_len, buf, reg);
502
			(void)consume(fp, stamp.scr_len, buf, reg);
503
			termset();
504
			atexit(termreset);
473
			break;
505
			break;
474
		case 'e':
506
		case 'e':
507
			termreset();
475
			if (!qflg)
508
			if (!qflg)
476
				(void)printf("\nScript done on %s",
509
				(void)printf("\nScript done on %s",
477
				    ctime(&tclock));
510
				    ctime(&tclock));

Return to bug 248377