Possible bug with socket code

Mark Dapoz mdapoz at hybrid.UUCP
Mon Oct 16 13:26:05 AEST 1989


I think I may have stumbled across a bug in the ipc code recently posted.  I
was working on trying to write a program which uses the locking(3C) facilities
and I kept running into problems.  Whenever I would call the locking() routine,
it would always return with an error, which perror indicates is invalid address.
If I remove the ipc device driver, the program works just fine.  I don't know
what the ipc device driver is doing, but whatever it is, it sure does interfere
with the locking() routine.  Below is the program which shows this behaviour.
The following error is reported when run with the ipc device driver.

Locking.......
lock: Bad address

The program should just lock the file "mutex" (create the file before running
the program) and then unlock it.
		-mark

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>

main()
{
	int fd;

	if ((fd = open("mutex", O_RDONLY)) < 0 ) {
		perror("open");
		exit(1);
	}
	printf("Locking.......\n");
	if (locking(fd, F_LOCK, 0L) < 0) {
		perror("lock");
		exit(1);
	}
	sleep(5);
	printf("Unlocking.......\n");
	if (locking(fd, F_ULOCK, 0L) < 0) {
		perror("unlock");
		exit(1);
	}
}
-- 
  Mark Dapoz  (mdapoz at hybrid.UUCP)  ...uunet!mnetor!hybrid!mdapoz

I remind you that humans are only a tiny minority in this galaxy.
	   -- Spock, "The Apple," stardate 3715.6.



More information about the Unix-pc.general mailing list