Problem with lockf on SunOS 3.5

Rangachari Anand anand at amax.npac.syr.edu
Mon Jun 26 01:18:03 AEST 1989


The following program works perfectly on SunOS 4.0.  When run on 3.5 the
following things happen.

  1. The program hangs. The process can not be killed even with
     kill -9

  2. The daemon lockd dies.

The program is shown below:
#include <stdio.h>
#include <sys/file.h>
#include <unistd.h>

main()
{
  int fd, res;

  fd = open("foo", O_WRONLY | O_CREAT);
  if (fd == -1) { perror("t1"); exit(0); }

  res = lockf(fd, F_LOCK, (long) 1);
  if (res == -1) { perror("t1"); exit(0); }
  printf("Lockf returns %d\n", res);

  res = lockf(fd, F_ULOCK, (long) 1);
  if (res == -1) { perror("t1"); exit(0); }
  printf("Lockf returns %d\n", res);

  res = lockf(fd, F_TEST, (long) 1);
  if (res == -1) { perror("t1"); exit(0); }
  printf("Lockf returns %d\n", res);
}

Does any one know what causes this problem.

                                           R.Anand

Internet:  anand at amax.npac.syr.edu
Bitnet:    ranand at sunrise



More information about the Comp.sys.sun mailing list