lockf() problem

lockf() problem

Post by Michael Lynggaa » Wed, 13 Jul 1994 02:55:53



As a newcommer to unix-programming I have a problem using lockf().
The following code have worked on several unix-systems but not on a NCR-box
"named" : Unix System V Release 4.0 Version 3.0 (WINS)
The program starts sleeping at the lockf() function.
(truss)     write(1, " B e f o r e   l o c k f".., 13)      = 13
               fcntl(4, F_SETLKW, 0x08047AF0)  (sleeping...)
Why ?

Thank you in advance.
Michael Lynggaard /Denmark

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>

void main ( argc, argv )
int argc;
char **argv;
{
int fd;
char szBuffer[80+1];

   printf("Waiting... Hit a key. (pid %d)", getpid());
   gets(szBuffer);

   umask( 002 );
   fd = open( "afile.tmp", O_CREAT | O_WRONLY, 0777 );
   if ( fd == -1 )
      {
      printf("Error in 'open'");
      exit( -1 );
      }

   printf("Before lockf\n");
   if ( lockf(fd, F_LOCK, 0L) == -1 )
      {
      printf("Error in 'lockf' (file may already be locked)");
      exit( -1 );
      }

   printf("Program is running. File lock is active until you hit a key.\n");
   gets(szBuffer);

   close(fd);
   exit( 0 );

Quote:}

 
 
 

1. sendmail/Linux 2.0 and lockf() problems

Just tried an upgrade to 2.0 today on a machine at work today, and sendmail
appears to not like it.  Any time a mail message tries to go through, the
following pops up:

Jun 18 12:52:17 noc sendmail[103]: MAA00103: SYSERR(root):cannot lockf(/etc/mai
lertable.dir, fd=6, type=1, omode=37777777777, euid=0): Device or resource busy

I'm running sendmail 8.7.5, kernel 2.0, and libc5.3.12 (tried with
libc5.2.18 also with no luck).  Sendmail 8.7.5 was compiled with gcc2.7.2
under the 2.0 kernel.

I notice in the kernel release notes that this exact problem is mentioned,
but it advises to upgrade to the latest version of sendmail.  Well... what
am I supposed to do if I AM running the latest sendmail?

Any ideas?

-Jon

--
   -------------------------------------------------------------------------
  *   Jon Green          *  GIT d- s+:+ a-- C++$ ULO++++$ P+ L++ E W+(--) *

* INS WAN Technician   *  t+ 5 X(+) R- tv+ b+ DI++ D++ G+ e+ h r++ y+   *
------------------------------------------------------------------------

2. Tiny Firewall and newsgroups and such

3. lockf problems...

4. Graphical login DISABLE

5. lockf() problems on solaris 2.6

6. problem with unresolved symbols 2.5.46

7. lockf problem on Solaris 2.4

8. Writing an application that uses bpp to control H/W through s-bus parallel port

9. lockf problems under 1.99.12

10. Sendmail lockf problem

11. lockf problem

12. lockf problem on SparcStation 2

13. Problem with lockf, please help me