Last change
on this file was 831, checked in by bird, 22 years ago |
Initial coding.
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
764 bytes
|
Line | |
---|
1 | #include <stdio.h>
|
---|
2 | #include <errno.h>
|
---|
3 | #include <unistd.h>
|
---|
4 | #include <sys/fcntl.h>
|
---|
5 |
|
---|
6 | int main(int argc, char **argv)
|
---|
7 | {
|
---|
8 | int rc;
|
---|
9 | int rcRet = 0;
|
---|
10 | int fd;
|
---|
11 | struct flock lock;
|
---|
12 |
|
---|
13 | fd = open(argv[0], O_RDONLY);
|
---|
14 | if (fd < 0)
|
---|
15 | {
|
---|
16 | printf("error: failed to open '%s', errno=%d\n", argv[0], errno);
|
---|
17 | return 1;
|
---|
18 | }
|
---|
19 |
|
---|
20 | lock.l_type = F_RDLCK;
|
---|
21 | lock.l_whence = SEEK_SET;
|
---|
22 | lock.l_start = 0;
|
---|
23 | lock.l_len = 0;
|
---|
24 | rc = fcntl(fd, F_SETLK, &lock);
|
---|
25 | if (rc)
|
---|
26 | {
|
---|
27 | rcRet++;
|
---|
28 | printf("error: lock rc=%d, errno=%d\n", rc, errno);
|
---|
29 | }
|
---|
30 | close(fd);
|
---|
31 |
|
---|
32 | if (rcRet)
|
---|
33 | printf("testcase failed\n");
|
---|
34 | else
|
---|
35 | printf("testcase succeeded\n");
|
---|
36 | return rcRet;
|
---|
37 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.