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:
parent
879210125e
commit
334a95086d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=26844
@ -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 */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user