Checking if a process opened a file

Tim Tsai it1 at Isis.MsState.Edu
Tue Apr 2 16:45:50 AEST 1991


  Is it possible to check if a process (possibly from another machine
via NFS) opened a file for reading/writing?  I've mucked with the
select() call, but the call always returns with the value 1.  What is
an "exceptional condition"?  Here's a sketch of what I've attempted
(with error checking, etc removed):

    infile = open ( filename, O_RDONLY );
    FD_ZERO ( &fdset );
    FD_SET ( infile, &fdset );
    for (;;)
    {
        result = select ( ulimit(), 0, 0, &fdset, 0 );
        printf ("exceptional condition on %s, result = %d\n", filename,
            result);
    }

  BTW, I know about named pipes.  I'm interested in regular files.

  This is on a Sun4, SunOS 4.1.1..  Thanks in advance for any help..

  PS:  I also tried poll(), with timeout set to -1 and events set to
  POLLPRI..  Same result.

--
  Never argue with a fool, people might not know the difference.
                                                       <Murphy's Law>



More information about the Comp.unix.programmer mailing list