Imply a 10-second connection timeout when querying remote queues, to

prevent lpq from hanging indefinately (well, 10 minutes are for sure
counting as `indefinately' in this case).
This commit is contained in:
joerg 1997-06-23 10:00:01 +00:00
parent c9bcb10bb6
commit 2dbf299912

View File

@ -73,6 +73,8 @@ static long totsize; /* total print job size in bytes */
static char *head0 = "Rank Owner Job Files";
static char *head1 = "Total Size\n";
static void alarmhandler __P((int));
/*
* Display the current state of the queue. Format = 1 if long format.
*/
@ -86,6 +88,7 @@ displayq(format)
struct queue **queue;
struct stat statb;
FILE *fp;
void (*savealrm)(int);
lflag = format;
totsize = 0;
@ -212,7 +215,10 @@ displayq(format)
(void) strcpy(cp, user[i]);
}
strcat(line, "\n");
savealrm = signal(SIGALRM, alarmhandler);
alarm(10);
fd = getport(RM, 0);
(void)signal(SIGALRM, savealrm);
if (fd < 0) {
if (from != host)
printf("%s: ", host);
@ -446,3 +452,10 @@ prank(n)
col += strlen(rline);
printf("%s", rline);
}
void
alarmhandler(signo)
int signo;
{
/* ignored */
}