Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
d0de57cf
Kaydet (Commit)
d0de57cf
authored
May 09, 2001
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Update the fcntl module documentation.
üst
152a25ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
30 deletions
+26
-30
libfcntl.tex
Doc/lib/libfcntl.tex
+26
-30
No files found.
Doc/lib/libfcntl.tex
Dosyayı görüntüle @
d0de57cf
...
@@ -11,8 +11,12 @@
...
@@ -11,8 +11,12 @@
This module performs file control and I/O control on file descriptors.
This module performs file control and I/O control on file descriptors.
It is an interface to the
\cfunction
{
fcntl()
}
and
\cfunction
{
ioctl()
}
It is an interface to the
\cfunction
{
fcntl()
}
and
\cfunction
{
ioctl()
}
\UNIX
{}
routines. File descriptors can be obtained with the
\UNIX
{}
routines.
\method
{
fileno()
}
method of a file or socket object.
All functions in this module take a file descriptor
\var
{
fd
}
as their
first argument. This can be an integer file descriptor, such as
returned by
\code
{
sys.stdin.fileno()
}
, or a file object, such as
\code
{
sys.stdin
}
itself.
The module defines the following functions:
The module defines the following functions:
...
@@ -20,22 +24,22 @@ The module defines the following functions:
...
@@ -20,22 +24,22 @@ The module defines the following functions:
\begin{funcdesc}
{
fcntl
}{
fd, op
\optional
{
, arg
}}
\begin{funcdesc}
{
fcntl
}{
fd, op
\optional
{
, arg
}}
Perform the requested operation on file descriptor
\var
{
fd
}
.
Perform the requested operation on file descriptor
\var
{
fd
}
.
The operation is defined by
\var
{
op
}
and is operating system
The operation is defined by
\var
{
op
}
and is operating system
dependent. T
ypically these codes can be retrieved from the library
dependent. T
hese codes are also found in the
\module
{
fcntl
}
module
\module
{
FCNTL
}
\refstmodindex
{
FCNTL
}
. The argument
\var
{
arg
}
module
. The argument
\var
{
arg
}
is optional, and defaults to the
i
s optional, and defaults to the integer value
\code
{
0
}
. When
i
nteger value
\code
{
0
}
. When present, it can either be an integer
present, it can either be an integer value, or a string. With
value, or a string. With the argument missing or an integer value,
the
argument missing or an integer value, the return value of this
the
return value of this function is the integer return value of the
function is the integer return value of the C
\cfunction
{
fcntl()
}
C
\cfunction
{
fcntl()
}
call. When the argument is a string it
call. When the argument is a string it represents a binar
y
represents a binary structure, e.g.
\
created b
y
structure, e.g.
\
created by
\function
{
struct.pack()
}
. The binary
\function
{
struct.pack()
}
. The binary data is copied to a buffer
data is copied to a buffer whose address is passed to the C
whose address is passed to the C
\cfunction
{
fcntl()
}
call. The
\cfunction
{
fcntl()
}
call. The return value after a successful call
return value after a successful call is the contents of the buffer,
is the contents of the buffer, converted to a string object. The length
converted to a string object. The length of the returned string
of the returned string will be the same as the length of the
\var
{
arg
}
will be the same as the length of the
\var
{
arg
}
argument. This is
argument. This is limited to 1024 bytes. If the information returned
limited to 1024 bytes. If the information returned in the buffer by
in the buffer by the operating system is larger than 1024 bytes,
the operating system is larger than 1024 bytes, this is most likely
t
his is most likely to result in a segmentation violation or a more
t
o result in a segmentation violation or a more subtle data
subtle data
corruption.
corruption.
If the
\cfunction
{
fcntl()
}
fails, an
\exception
{
IOError
}
is
If the
\cfunction
{
fcntl()
}
fails, an
\exception
{
IOError
}
is
raised.
raised.
...
@@ -90,26 +94,18 @@ The default for \var{start} is 0, which means to start at the
...
@@ -90,26 +94,18 @@ The default for \var{start} is 0, which means to start at the
beginning of the file. The default for
\var
{
length
}
is 0 which means
beginning of the file. The default for
\var
{
length
}
is 0 which means
to lock to the end of the file. The default for
\var
{
whence
}
is also
to lock to the end of the file. The default for
\var
{
whence
}
is also
0.
0.
\end{funcdesc}
\end{funcdesc}
If the library modules
\module
{
FCNTL
}
\refstmodindex
{
FCNTL
}
or
\module
{
IOCTL
}
\refstmodindex
{
IOCTL
}
are missing, you can find the
opcodes in the C include files
\code
{
<sys/fcntl.h>
}
and
\code
{
<sys/ioctl.h>
}
. You can create the modules yourself with the
\program
{
h2py
}
script, found in the
\file
{
Tools/scripts/
}
directory.
Examples (all on a SVR4 compliant system):
Examples (all on a SVR4 compliant system):
\begin{verbatim}
\begin{verbatim}
import struct, fcntl
, FCNTL
import struct, fcntl
file = open(...)
file = open(...)
rv = fcntl(file
.fileno(), FCNTL.F
_
SETFL, FCNTL
.O
_
NDELAY)
rv = fcntl(file
, fcntl.F
_
SETFL, os
.O
_
NDELAY)
lockdata = struct.pack('hhllhh',
FCNTL
.F
_
WRLCK, 0, 0, 0, 0, 0)
lockdata = struct.pack('hhllhh',
fcntl
.F
_
WRLCK, 0, 0, 0, 0, 0)
rv = fcntl.fcntl(file
.fileno(), FCNTL
.F
_
SETLKW, lockdata)
rv = fcntl.fcntl(file
, fcntl
.F
_
SETLKW, lockdata)
\end{verbatim}
\end{verbatim}
Note that in the first example the return value variable
\var
{
rv
}
will
Note that in the first example the return value variable
\var
{
rv
}
will
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment