summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lpr/lpd
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1996-05-05 14:04:33 +0000
committerjoerg <joerg@FreeBSD.org>1996-05-05 14:04:33 +0000
commitbfed4e31e9e01282e9c03ffa90a60456deb852fb (patch)
treec6c301c267c3c659876025ac6f48aa4c99254939 /usr.sbin/lpr/lpd
parentecfc9b829b4a7d5106486f9f84ca5c49e689ca09 (diff)
parent0291e848bc787305335af649ac14bc8fe5a19a49 (diff)
downloadFreeBSD-src-bfed4e31e9e01282e9c03ffa90a60456deb852fb.zip
FreeBSD-src-bfed4e31e9e01282e9c03ffa90a60456deb852fb.tar.gz
This commit was generated by cvs2svn to compensate for changes in r15637,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'usr.sbin/lpr/lpd')
-rw-r--r--usr.sbin/lpr/lpd/lpd.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c
index aaf72b7..3b23359 100644
--- a/usr.sbin/lpr/lpd/lpd.c
+++ b/usr.sbin/lpr/lpd/lpd.c
@@ -39,7 +39,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)lpd.c 8.4 (Berkeley) 4/17/94";
+static char sccsid[] = "@(#)lpd.c 8.7 (Berkeley) 5/10/95";
#endif /* not lint */
/*
@@ -77,6 +77,7 @@ static char sccsid[] = "@(#)lpd.c 8.4 (Berkeley) 4/17/94";
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/stat.h>
+#include <sys/file.h>
#include <netinet/in.h>
#include <netdb.h>
@@ -103,6 +104,7 @@ static void mcleanup __P((int));
static void doit __P((void));
static void startup __P((void));
static void chkhost __P((struct sockaddr_in *));
+static int ckqueue __P((char *));
int
main(argc, argv)
@@ -429,11 +431,17 @@ startup()
* Restart the daemons.
*/
while (cgetnext(&buf, printcapdb) > 0) {
+ if (ckqueue(buf) <= 0) {
+ free(buf);
+ continue; /* no work to do for this printer */
+ }
for (cp = buf; *cp; cp++)
if (*cp == '|' || *cp == ':') {
*cp = '\0';
break;
}
+ if (lflag)
+ syslog(LOG_INFO, "work for %s", buf);
if ((pid = fork()) < 0) {
syslog(LOG_WARNING, "startup: cannot fork");
mcleanup(0);
@@ -442,8 +450,35 @@ startup()
printer = buf;
cgetclose();
printjob();
+ /* NOTREACHED */
}
+ else free(buf);
+ }
+}
+
+/*
+ * Make sure there's some work to do before forking off a child
+ */
+static int
+ckqueue(cap)
+ char *cap;
+{
+ register struct dirent *d;
+ DIR *dirp;
+ char *spooldir;
+
+ if (cgetstr(cap, "sd", &spooldir) == -1)
+ spooldir = _PATH_DEFSPOOL;
+ if ((dirp = opendir(spooldir)) == NULL)
+ return (-1);
+ while ((d = readdir(dirp)) != NULL) {
+ if (d->d_name[0] != 'c' || d->d_name[1] != 'f')
+ continue; /* daemon control files only */
+ closedir(dirp);
+ return (1); /* found something */
}
+ closedir(dirp);
+ return (0);
}
#define DUMMY ":nobody::"
OpenPOWER on IntegriCloud