DataMuseum.dk

Presents historical artifacts from the history of:

Commodore CBM-900

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Commodore CBM-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦ef2e8cd47⟧ TextFile

    Length: 768 (0x300)
    Types: TextFile
    Notes: UNIX file
    Names: »lpskip.c«

Derivation

└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
    └─⟦f4b8d8c84⟧ UNIX V7 Filesystem
        └─ ⟦this⟧ »cmd/lpr/lpskip.c« 

TextFile

/*
 * Cause the line printer daemon to
 * skip the current listing.
 * With `-r' option, make it restart the
 * current listing.
 * SIGTRAP is used for skipping; SIGREST for restarting.
 * (NOTE: this should be setuid to daemon).
 */

#include <stdio.h>
#include <signal.h>

char	lockfile[] = "/usr/spool/lpd/dpid";

main(argc, argv)
char *argv[];
{
	int pid;
	register int fd;
	register int sig = SIGTRAP;

	if (argc>1 && *argv[1]=='-') {
		if (argv[1][1]=='r' && argv[1][2]=='\0')
			sig = SIGREST;
		else
			usage();
	}
	if ((fd = open(lockfile, 0)) < 0
	 || read(fd, &pid, sizeof pid) != sizeof (pid)
	 || kill(pid, sig) < 0) {
		fprintf(stderr, "Line printer daemon not active\n");
		exit(1);
	}
}

usage()
{
	fprintf(stderr, "Usage: lpskip [-r]\n");
	exit(1);
}