~kris/9p

9hist

5188277e2c1a4e93d97e323f8347315ca5747fc2 — David du Colombier 33 years ago ef2dff1
Plan 9 from Bell Labs 1993-09-01
1 files changed, 15 insertions(+), 2 deletions(-)

M boot/aux.c
M boot/aux.c => boot/aux.c +15 -2
@@ 136,22 136,35 @@ srvcreate(char *name, int fd)
	close(f);
}

static int
catchint(void *a, char *note)
{
	USED(a);
	if(strcmp(note, "alarm") == 0)
		return 1;
	return 0;
}

int
outin(char *prompt, char *def, int len)
{
	int n;
	char buf[256];

	atnotify(catchint, 1);
	if(cpuflag)
		alarm(60*1000);
		alarm(15*1000);
	do{
		print("%s[%s]: ", prompt, *def ? def : "no default");
		n = read(0, buf, len);
		if(cpuflag)
			alarm(15*1000);
	}while(n==0);
	if(cpuflag)
		alarm(0);
	atnotify(catchint, 0);
	if(n < 0)
		fatal("can't read #c/cons or timeout; please reboot");
		return 1;
	if(n != 1){
		buf[n-1] = 0;
		strcpy(def, buf);