- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: pstat_getpathname releases fcntl lock?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-05-2009 04:43 AM
тАО10-05-2009 04:43 AM
pstat_getpathname releases fcntl lock?
Example output of the program follows. The "waiting" pid should not say "got lock" until the holding pid says "releasing lock". Commenting out the call to pstat_getpathname fixes this behavior.
6869: got lock on 3
6869: sleeping...
6868: waiting for lock on 3...
6869: calling pstat_getpathname
6868: got lock on 3
Code:
#define _PSTAT64
#include
#include
#include
#include
#include
#include
int main(int argc, char *argv[])
{
struct flock lock;
pid_t pid;
int result;
int fd;
pid = fork();
fd = open("/tmp/locktest",O_RDWR|O_CREAT,0666);
if (fd == -1) return EXIT_FAILURE;
printf("%5d: waiting for lock on %d...\n",getpid(),fd);
lock.l_type = F_WRLCK;
lock.l_start = 0;
lock.l_len = 0;
lock.l_whence = SEEK_SET;
do {
errno = 0;
result = fcntl(fd,F_SETLKW,&lock);
} while (result == -1 && errno == EINTR);
if (result == -1) return EXIT_FAILURE;
printf("%5d: got lock on %d\n",getpid(),fd);
printf("%5d: sleeping...\n",getpid());
sleep(1);
printf("%5d: calling pstat_getpathname\n",getpid());
{
char filename[PATH_MAX];
struct pst_fileinfo2 psf;
pstat_getfile2(&psf,sizeof(psf),0,fd,getpid());
pstat_getpathname(filename,sizeof(filename),&psf.psf_fid);
}
printf("%5d: sleeping...\n",getpid());
sleep(2);
printf("%5d: releasing lock on %d\n",getpid(),fd);
close(fd);
if (pid != 0) waitpid(pid,NULL,0);
return EXIT_SUCCESS;
}
- Tags:
- pstat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-05-2009 04:47 AM
тАО10-05-2009 04:47 AM
Re: pstat_getpathname releases fcntl lock?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-05-2009 04:49 AM
тАО10-05-2009 04:49 AM
Re: pstat_getpathname releases fcntl lock?
And exactly what release is this running on? Do:
# uname -a
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-05-2009 06:09 AM
тАО10-05-2009 06:09 AM
Re: pstat_getpathname releases fcntl lock?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-05-2009 07:02 AM
тАО10-05-2009 07:02 AM
Re: pstat_getpathname releases fcntl lock?
Questions of this technical nature are going to have to go to the Response Center.
How are you synchronizing your parent/child access to that file? I would expect you should create it before you fork.
There doesn't seem to be anything obviously wrong with your program.