summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lpr
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1997-06-23 10:00:01 +0000
committerjoerg <joerg@FreeBSD.org>1997-06-23 10:00:01 +0000
commit9289d9c4986115e0de14a3e17a39a6dc24ca0ac1 (patch)
treeeb7103f2e5b187887198005126e0b47921317d0e /usr.sbin/lpr
parent0c0bda62e2cffb57e61ba0c410acf6b2773c9971 (diff)
downloadFreeBSD-src-9289d9c4986115e0de14a3e17a39a6dc24ca0ac1.zip
FreeBSD-src-9289d9c4986115e0de14a3e17a39a6dc24ca0ac1.tar.gz
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).
Diffstat (limited to 'usr.sbin/lpr')
-rw-r--r--usr.sbin/lpr/common_source/displayq.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c
index a974d6f..a5b8b26 100644
--- a/usr.sbin/lpr/common_source/displayq.c
+++ b/usr.sbin/lpr/common_source/displayq.c
@@ -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 */
+}
OpenPOWER on IntegriCloud