Subject: bin/509: lpc always says: no daemon present
To: None <gnats-admin@sun-lamp.cs.berkeley.edu>
From: Andrew Wheadon <andrew@wipux2.wifo.uni-mannheim.de>
List: netbsd-bugs
Date: 10/09/1994 07:35:05
>Number:         509
>Category:       bin
>Synopsis:       flock-checking of lpd-lock file wrong ?
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct  9 07:35:04 1994
>Originator:     Andrew Wheadon
>Organization:
The cost of living hasn't affected it's popularity. (unknown)
current	release=doc host=wipux2.wifo.uni-mannheim.de \ "NetBSD-current mirror"
hostbase=/mit/ftp/pub/NetBSD base=/usr prefix=/usr backup delete use-rel-suffix
>Release:        
>Environment:
	
System: NetBSD wipux2 1.0_BETA NetBSD 1.0_BETA (WIPUX) #0: Sat Oct 8 14:56:21 MET 1994 toor@wipux2:/src/src/sys/arch/i386/compile/WIPUX i386


>Description:
	Whenever I used 'lpc' to check the status, it always says
	I have no daemon present. If I ps ax | grep lpd, it shows
	me that the daemon is running. The printing also functions
	fine. (I print over a remote printer).
	If you can't repeat this please tell me as it'll mean I'm
	doing something wrong.
	
>How-To-Repeat:
	setup printing. start "lpd", run "lpc status".
	
>Fix:
	I looked through src/usr.sbin/lpr/lpc/cmds.c and patched it
	like show lower down, then it works. It seems to open the
	lock file (which produces a positive value, and it seems
	to be able to flock(fd, LOCK_SH|LOCK_NB) the lock-file which
	produces a value of zero, the later being undesired by lpc
	for some login I fail to understand. Does it expect the 
	lock-file to locked-exclusivly by the daemon or something ? 

*** ../cmds.c	Wed May 18 15:11:12 1994
--- cmds.c	Sun Oct  9 15:14:35 1994
***************
*** 813,817 ****
  		printf("\t%d entries in spool area\n", i);
  	fd = open(line, O_RDONLY);
! 	if (fd < 0 || flock(fd, LOCK_SH|LOCK_NB) == 0) {
  		(void) close(fd);	/* unlocks as well */
  		printf("\tno daemon present\n");
--- 813,817 ----
  		printf("\t%d entries in spool area\n", i);
  	fd = open(line, O_RDONLY);
! 	if (fd < 0) {
  		(void) close(fd);	/* unlocks as well */
  		printf("\tno daemon present\n");
	
>Audit-Trail:
>Unformatted: