File: flock.2

package info (click to toggle)
manpages-ja 0.5.0.0.20080615-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 20,508 kB
  • ctags: 1
  • sloc: sh: 13,690; perl: 157; makefile: 114
file content (218 lines) | stat: -rw-r--r-- 6,815 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu) and
.\" and Copyright 2002 Michael Kerrisk
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Modified Fri Jan 31 16:26:07 1997 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified Fri Dec 11 17:57:27 1998 by Jamie Lokier <jamie@imbolc.ucc.ie>
.\" Modified 24 Apr 2002 by Michael Kerrisk <mtk.manpages@gmail.com>
.\"	Substantial rewrites and additions
.\" 2005-05-10 mtk, noted that lock conversions are not atomic.
.\"
.\" Japanese Version Copyright (c) 1996 Takeshi Ueno
.\"         all rights reserved.
.\" Translated 1996-07-03, Takeshi Ueno <tueno@vio.co.jp>
.\" Modified 1997-12-14, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Modified 1999-08-14, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Modified 2002-09-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Modified 2005-02-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\"
.TH FLOCK 2 2002-04-24 "Linux" "Linux Programmer's Manual"
.SH ̾
flock \- ץ󤵤줿եФ륢ɥХꡦåŬѡԤ
.SH 
.B #include <sys/file.h>
.sp
.BI "int flock(int " fd ", int " operation );
.SH 
ץ󤵤줿ե˥ɥХꡦå(advisory lock)Ŭ
Ԥ
ե
.I fd
ǻꤹ롣
.I operation
ˤϰʲΤ줫Ĥꤹ:
.RS 4
.TP 9
.B LOCK_SH
ͭåŬѤ롣 ꤷեФơ
İʾΥץƱ˶ͭåݻ뤳ȤǤ롣
.TP
.B LOCK_EX
¾åŬѤ롣  ꤷեФơ
ĤΥץƱ¾åݻ뤳ȤǤ롣
.TP
.B LOCK_UN
ΥץݻƤ¸Υå롣
.RE
.PP
.BR flock ()
ƤӽФȤˡꤷå̤Ȱۤʤḁ̊ץˤä
ݻƤȡ
.BR flock ()
 (block) 뤳Ȥ롣
 (non-blocking) פ׵Ԥˤϡ
嵭 (operation) 
.B LOCK_NB
¤ηǻꤹ롣

ĤΥե˶ͭå¾åƱꤹ뤳ȤϤǤʤ

.BR flock ()
ˤäƺåϡ
ץ󤵤줿եΥơ֥롦ȥȴϢդ롣
äơե롦ǥץʣ
.RB ( fork (2)

.BR dup (2)
ʤɤˤ) Ʊå򻲾Ȥ
Υե롦ǥץΤɤȤäƤ
ΥåѹǤ롣
ޤåβϡ
嵭ʣΥե롦ǥץΤ줫Ф
Ū
.B LOCK_UN
ؼ礫Υե롦ǥץ٤
Ĥ줿˹Ԥ롣

ץ
.BR open (2)
(⤷Ʊͤˡ) ȤäƱեФ
ʣΥǥץ硢
.BR flock ()
ϤʣΥǥץơΩΤΤȤư
Υե롦ǥץΰĤȤäƥեå褦
ݡΥå׵ϡƤӽФΥץΥե̤
ǥץͳǤǤꤷƤåˤäƵݤ礬롣

ĤΥץϡĤΥեФ (ͭå¾åΤ)
줫ΥåǤʤ
˥å줿եФ
.BR flock ()
ƤӽФȡ¸Υå򿷤å⡼ɤѹ뤳Ȥˤʤ롣

.BR flock ()
ˤ줿å
.BR execve (2)
¸롣

ͭå¾å⡢ե뤬ɤΥ⡼ɤǥץ󤵤줿
طʤŬѤ뤳ȤǤ롣
.SH ֤
ξ硢0 ֤롣顼ξϡ\-1 ֤졢
.I errno
Ŭڤͤꤵ롣
.SH 顼
.TP
.B EBADF
.I fd
ץ󤵤줿ե롦ǥץǤϤʤ
.TP
.B EINTR
åγԤäƤ֤ˡϥɥˤª줿ʥ

.BR flock ()
Ǥ줿
.TP
.B EINVAL
.I oepration
̵Ǥ롣
.TP
.B ENOLCK
å쥳ɤƤ뤿Υ꤬­Ƥ롣
.TP
.B EWOULDBLOCK
ꤷե뤬åƤꡢ
.B LOCK_NB
ե饰ꤵƤ롣
.SH 
4.4BSD
.RB ( flock ()
 4.2BSD Ǻǽо줷)
.BR fcntl (2)
ǼƤΤʤɤޤȡ
.BR flock ()
εǽϤۤȤɤ Unix ƥǼƤ롣
.SH 
.BR flock ()
 NFS ΥեΥå򤷤ʤ
.BR fcntl (2)
Ѥ뤳ȡˤꡢʬ˿С Linux ȡåǽ
ݡȤ NFS ФѤ뤳ȤˤꡢNFS ǥåǤ롣
.PP
kernel 2.0 ʹߤǤϡ
.BR flock ()
ϡGNU C 饤֥Ǥ
.BR fcntl (2)
ƤӽФƤΥߥ졼ǤϤʤ
켫ΤƥॳȤƼƤ롣
ˤä BSD Ǥưã:
.BR flock ()

.BR fcntl (2)
ŬѤåμ̤ˤߺѤʤʤꡢ
.BR flock ()
ǥåɥå򸡽Фʤʤ롣
.PP
.BR flock ()
ɥХꡦåŬѤ롣äơեŬڤʥ
ͿƤСץ
.BR flock ()
λѤ̵뤷ơեؤϤԤȤǤ롣
.PP
.BR flock ()

.BR fcntl (2)
 fork 줿ץ
.BR dup (2)
ǰäư򤹤롣
.BR flock ()

.BR fcntl (2)
ȤäƼƤ륷ƥǤϡ
.BR flock ()
ưϤΥޥ˥奢롦ڡ˵ܤƤΤȤϰ㤦
.PP
åѴ (ͭå¾åء⤷Ϥȿ) ȥߥå
Ԥ뤳ȤݾڤƤʤ: ¸Υåޤ졢줫鿷
åꤵ롣 2ĤΥƥåפδ֤ˡ¾ΥץνԤ
å׵᤬ǧ뤫⤷줺̤ȤѴ (block) ꡢ
.RB ( LOCK_NB
ꤵ줿ˤ) Ԥꤹ롣
(ϸ BSD ưǤꡢ¿¾μǤⵯ롣)
.\" ͥ 2.5.21 Ǿưѹ줿: åѴκ
.\" ΥåԤȤƤץǹͥȤʤ -- mtk
.SH Ϣ
.BR close (2),
.BR dup (2),
.BR execve (2),
.BR fcntl (2),
.BR fork (2),
.BR open (2),
.BR lockf (3)

ͥ륽
.IR Documentation/locks.txt ,
.I Documentation/mandatory.txt
⻲ȤΤȡ