Bugzilla – Attachment 1495 Details for
Bug 4992
При закрытии файлового дескриптора дочерним процессом сбрасываются блокировки
EN
|
RU
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Тест описывающий проблему
test_lock.c (text/plain), 2.79 KB, created by
Pavel Shilovsky
on 2010-11-18 03:58:26 MSK
(
hide
)
Description:
Тест описывающий проблему
Filename:
MIME Type:
Creator:
Pavel Shilovsky
Created:
2010-11-18 03:58:26 MSK
Size:
2.79 KB
patch
obsolete
>#include <stdio.h> > >#include <sys/types.h> >#include <sys/stat.h> >#include <fcntl.h> >#include <errno.h> >#include <string.h> >#include <sys/socket.h> > >#include <unistd.h> > >int main () >{ > char buf[13030]; > int len, fd, rc, ipc[2], rc2, i; > struct flock flk; > > pid_t ppid = getpid(); > > printf("start %d\n", getpid()); > > fd = open("PDOXUSRS.NET", O_CREAT | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR); > for(i = 0; i < 16; i++) > write(fd, "a", 1); > close(fd); > > fd = open("PDOXUSRS.NET", O_RDWR); > flk.l_type = F_WRLCK; > flk.l_whence = SEEK_SET; > flk.l_start = 0; > flk.l_len = 1; > > if (fcntl(fd, F_SETLK, &flk) < 0) > fprintf(stderr, "fcntl set lock on %d failed (%s)\n", fd, strerror(errno)); > > rc = fork(); > if (rc < 0) { > fprintf(stderr, "fork failed\n"); > return 1; > } > > if (rc == 0) { > memset(&flk, 0, sizeof(flk)); > flk.l_type = F_WRLCK; > flk.l_whence = SEEK_SET; > flk.l_start = 0; > flk.l_len = 1; > > if (fcntl(fd, F_GETLK, &flk) < 0) > fprintf(stderr, "ch1: fcntl get lock on %d failed (%s)\n", fd, strerror(errno)); > if (flk.l_type == F_UNLCK) > fprintf(stderr, "ch1: unlck\n"); > else > fprintf(stderr, "ch1: locked\n"); > close(fd); > fprintf(stderr, "ch1: done\n"); > return 0; > } > sleep(1); > rc = fork(); > if (rc < 0) { > fprintf(stderr, "fork2 failed\n"); > return 1; > } > if (rc == 0) { > memset(&flk, 0, sizeof(flk)); > flk.l_type = F_WRLCK; > flk.l_whence = SEEK_SET; > flk.l_start = 0; > flk.l_len = 1; > > if (fcntl(fd, F_GETLK, &flk) < 0) > fprintf(stderr, "ch2: fcntl get lock on %d failed (%s)\n", fd, strerror(errno)); > if (flk.l_type == F_UNLCK) > fprintf(stderr, "ch2: unlck\n"); > else > fprintf(stderr, "ch2: locked\n"); > > flk.l_type = F_UNLCK; > flk.l_whence = SEEK_SET; > flk.l_start = 0; > flk.l_len = 1; > if (fcntl(fd, F_SETLK, &flk) < 0) > fprintf(stderr, "ch2: fcntl set lock on %d failed (%s)\n", fd, strerror(errno)); > fprintf(stderr, "ch2: done\n"); > return 0; > } > sleep(1); > rc = fork(); > if (rc < 0) { > fprintf(stderr, "fork3 failed\n"); > return 1; > } > if (rc == 0) { > memset(&flk, 0, sizeof(flk)); > flk.l_type = F_WRLCK; > flk.l_whence = SEEK_SET; > flk.l_start = 0; > flk.l_len = 1; > > if (fcntl(fd, F_GETLK, &flk) < 0) > fprintf(stderr, "ch3: fcntl get lock on %d failed (%s)\n", fd, strerror(errno)); > if (flk.l_type == F_UNLCK) > fprintf(stderr, "ch3: unlck\n"); > else > fprintf(stderr, "ch3: locked\n"); > return 0; > } > sleep(1); > printf("done\n"); >}
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 4992
: 1495