Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 161405 Details for
Bug 252000
flock demotion from exclusive to shared is incorrect
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
Get a shared lock then attempt to promote to an exclusive lock
flock_SH_EX.c (text/x-csrc), 1.33 KB, created by
Matt Brookover
on 2007-08-15 21:24:41 UTC
(
hide
)
Description:
Get a shared lock then attempt to promote to an exclusive lock
Filename:
MIME Type:
Creator:
Matt Brookover
Created:
2007-08-15 21:24:41 UTC
Size:
1.33 KB
patch
obsolete
>#include <stdio.h> >#include <unistd.h> >#include <sys/types.h> >#include <sys/stat.h> >#include <fcntl.h> >#include <sys/file.h> >#include <string.h> >#include <time.h> >#include <errno.h> > >int readlock(char *filename) >{ > int fd; > > if ((fd=open(filename,O_CREAT|O_RDWR,S_IRUSR|S_IWUSR|S_IRGRP))==-1) > { > fprintf (stderr,"Could not open %s:",filename); > perror (""); > exit(1); > } > > while (flock(fd,LOCK_SH) == -1) > { > if (errno!=EAGAIN) > { > fprintf (stderr,"Could not get shared lock on %s errno=%s:",filename,strerror(errno)); > exit(1); > } > printf ("%s locked, trying again to get shared lock\n",filename); > sleep (2); > } > > printf ("Have shared lock, hit return to promote shared lock to exclusive lock on %s\n",filename); > fgetc(stdin); > printf ("Waiting to get exclusive lock\n"); > while (flock(fd,LOCK_EX) == -1) > { > if (errno!=EAGAIN) > { > fprintf (stderr,"Could not get exclusive lock on %s errno=%s\n",filename,strerror(errno)); > exit(1); > } > printf ("%s locked, trying again to get exclusive lock\n",filename); > sleep (2); > } > > printf ("Have exclusive lock, hit return to free exclusive lock on %s and exit\n",filename); > fgetc(stdin); > > if (flock(fd,LOCK_UN) == -1) > { > fprintf (stderr,"Could unlock %s:",filename); > perror (""); > exit(1); > } > > close(fd); >} > >main(int argc, char *argv[]) >{ > int fd; > int i; > fd=readlock(argv[1]); >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 252000
:
161204
|
161205
| 161405 |
161406