File: write.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 (236 lines) | stat: -rw-r--r-- 7,136 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" This manpage is Copyright (C) 1992 Drew Eckhardt;
.\"                               1993 Michael Haardt, Ian Jackson.
.\" and Copyright (C) 2007 Michael Kerrisk <mtk.manpages@gmail.com>
.\"
.\" 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 Sat Jul 24 13:35:59 1993 by Rik Faith <faith@cs.unc.edu>
.\" Modified Sun Nov 28 17:19:01 1993 by Rik Faith <faith@cs.unc.edu>
.\" Modified Sat Jan 13 12:58:08 1996 by Michael Haardt
.\"   <michael@cantor.informatik.rwth-aachen.de>
.\" Modified Sun Jul 21 18:59:33 1996 by Andries Brouwer <aeb@cwi.nl>
.\" 2001-12-13 added remark by Zack Weinberg
.\" 2007-06-18 mtk:
.\"    	Added details about seekable files and file offset.
.\"	Noted that write() may write less than 'count' bytes, and
.\"	gave some examples of why this might occur.
.\"	Noted what happens if write() is interrupted by a signal.
.\"
.\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
.\"         all rights reserved.
.\" Translated Tue Mar  4 00:18:20 JST 1997
.\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated & Modified Wed Jun 13 20:57:55 JST 2001
.\"         by Yuichi SATO <ysato@h4.dion.ne.jp>
.\" Updated Mon Jun 25 JST 2001 by Kentaro Shirakata <argrath@ub32.org>
.\" Updated Fri Dec 21 JST 2001 by Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2002-09-24 by Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2005-10-14 by Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2007-05-01, Akihiro MOTOKI, LDP v2.46
.\" Updated 2007-09-01, Akihiro MOTOKI, LDP v2.64
.\"
.\"WORD:	descriptor		ǥץ
.\"WORD:	buffer			Хåե
.\"WORD:	file system		ե롦ƥ
.\"WORD:	object			֥
.\"WORD:	pipe			ѥ
.\"WORD:	socket			å
.\"WORD:	signal			ʥ
.\"WORD:	catch			(catch)
.\"WORD:	block			(block)
.\"WORD:	interrupt		
.\"WORD:	non-blocking I/O	 I/O
.\"WORD:	device			ǥХ
.\"WORD:	low-level I/O           ٥ I/O
.\"
.TH WRITE 2 2007-06-18 "Linux" "Linux Programmer's Manual"
.SH ̾
write \- ե롦ǥץ (file descriptor) ˽񤭹
.SH 
.B #include <unistd.h>
.sp
.BI "ssize_t write(int " fd ", const void *" buf ", size_t " count );
.SH 
.BR write ()
ϡ
.I buf
ؤХåե顢ե롦ǥץ
.I fd
Ȥեء
.I count
ХȤ񤭹ࡣ

񤭹ޤХȿ
.I count
⾮ʤ뤳Ȥ롣
㤨С񤭹оݤʪǥ˽ʬΰ褬ʤ硢
.B RLIMIT_FSIZE
ã
.RB ( setrlimit (2)
)
.I count
Х̤ν񤭹ߤԤ줿
ƤӽФʥϥɥˤޤ줿硢
ʤɤǤ롣
.RB ( pipe (7)
⻲ȤΤȡ)

seek ǽʥե (Ĥޤ
.BR lseek (2)
ŬѤǤե롢㤨̾Υե) Ǥϡ
񤭹ߤϸߤΥե롦եåȤԤ졢
ե롦եåȤϼºݤ˽񤭹ߤԤ줿Хȿʬ
û롣ե뤬
.B O_APPEND

.BR open (2)
줿硢ե롦եåȤϽ񤭹
եꤵ롣
ե롦եåȤĴȽ񤭹ϥȥߥåʽȤ
¹Ԥ롣

POSIX 
.BR write ()
Ԥʤ줿˼¹Ԥ
.BR read (2)

ǡ֤Ȥ׵ᤷƤ롣
ƤΥե롦ƥब POSIX ǤϤʤդ뤳ȡ
.SH ֤
硢񤭹ޤ줿Хȿ֤
(ϲ񤭹ޤʤäȤ򼨤)
顼ʤ \-1 ֤졢\fIerrno\fP Ŭڤꤵ롣

\fIcount\fP  0 ǡ
.I fd
̾Υե (regular file) 򻲾ȤƤ硢
.BR write ()
ϸҤΥ顼Τ줫򸡽Ф硢Ԥ֤Ȥ롣
顼Фʤäϡ
0 ֤¾˲αƶͿʤ
\fIcount\fP  0 ǡ
.I fd
̾ΥեʳΥե򻲾ȤƤ硢
η̤ϵꤵƤʤ
.SH 顼
.TP
.B EAGAIN
եǥץ
.I fd
ߥ⡼
.RB ( O_NONBLOCK )
ꤵƤơ
񤭹ߤ (block) 
.TP
.B EBADF
.I fd
ͭʥե롦ǥץǤʤ񤭹ߤΤ˥ץ
(open) Ƥʤ
.TP
.B EFAULT
.I buf
ǽʥɥ쥹 (address space) γˤ롣
.TP
.B EFBIG
κե륵ޤϥץΥե륵¤
Ķƥե˽񤭹⤦Ȥ
ޤϵĤ줿եåͤθ³Ķΰ֤
񤭹⤦Ȥ
.TP
.B EINTR
Υǡ񤫤ʤ֤˥ʥˤޤ줿 (interrupt)
.TP
.B EINVAL
.I fd
񤭹ߤŬڤʥ֥Ȥ򻲾ȤƤ롣
⤷ϡե뤬
.B O_DIRECT
ե饰ꤷƥץ󤵤Ƥ뤬
.I buf
˻ꤵ줿ɥ쥹
.I count
˻ꤵ줿͡
ߤΥե륪եåȤΤ줫
饤ȤŬڤǤ롣
.TP
.B EIO
inode ν٥ (low-level) I/O 顼ȯ
.TP
.B ENOSPC
.I fd
ˤäƻȤեޤǥХ (device) ˽ʬʶʤ
.TP
.B EPIPE
.I fd
ѥ (pipe) å (socket) ³Ƥꡢ
ȿ¦ (ɤ߹¦)  (close) Ƥ롣
줬ȯˤϡ񤭹ߤԤʤץ
.B SIGPIPE
ʥ (signal)롣
(äơץबΥʥ (catch) (block)̵ (ignore)
Τߡwrite ֤ͤ򻲾ȤǤ롣)
.PP
.I fd
³줿֥ȤˤäƤϡ¾Υ顼뤫⤷ʤ
.SH 
SVr4, 4.3BSD, POSIX.1-2001.
.\" SVr4 ˤ¾ EDEADLK, ENOLCK, ENOLNK,
.\" ENOSR, ENXIO, ERANGE 顼ˤĤƤεҤ롣

SVr4 Ǥ write ޤȡǡ񤭹ޤľǤϤʤ
λ
.B EINTR
֤롣
.SH 
.BR write ()
֤äƤƤ⡢ǡǥ˵Ͽ줿Ȥ
ݾڤΤǤϤʤ
ºݡǡΤΥڡݤ줿ȤݾڤʤȤ
Хäݤ⤢롣
μ¤ˤͣˡϡ
ƤΥǡ write 
.BR fsync (2)
ƤӽФȤǤ롣

.BR write ()
 1 ХȤ񤭹ޤʤ˥ʥϥɥˤޤ줿硢
.BR write ()
ϥ顼
.B EINTR
ǼԤ롣
1ХȤǤ񤭹dzޤ줿ˤϡ
.BR write ()
񤭹Хȿ֤
.SH Ϣ
.BR close (2),
.BR fcntl (2),
.BR fsync (2),
.BR ioctl (2),
.BR lseek (2),
.BR open (2),
.BR pwrite (2),
.BR read (2),
.BR select (2),
.BR writev (2),
.BR fwrite (3)