09-30-2008
"Under no circumstances" does not apply to slow read & write devices. There are no guarantees there, as far as I know.
Why are you not using aio? aio_write(), etc. Instead of worrying about all this. aio_read & aio_write calls do not block. They complete and then fail later if there was a serious system problem, or they terminate early if you call aio_cancel. But they do not block. This applies to POSIX-conformant OSes only.
See the opengroup on aio_write:
aio_write
The aio calls were designed so that you call them whenever, then come back later to get the results. This design precludes blocking. They are asynchronous in the best sense.
10 More Discussions You Might Find Interesting
1. Programming
Hi,
Could you please tell me how can I know which position a given read descriptor ocuppies in the descriptors table.
I know that, for instance, 'stdin' ocuppies position ... what about the others descriptors that I create usings pipes or sockets??
Thanks!
P.S.: Sorry for my bad English (2 Replies)
Discussion started by: jnuno
2 Replies
2. Programming
How can 'popen()' be used for reading and writing to opening pipe?
If i try 'popen("prog", "rw")'
and then put and get chars - it does
not work.
What is wrong? (1 Reply)
Discussion started by: szzz
1 Replies
3. Shell Programming and Scripting
I have tried to show the file name whose size is greater than 200 byte in current directory.
Please help me.
ls -l | tr -s " " " " | cut -f 5,9 -d " " >out.txt
#set -a x `cat out.txt`
i=0
`cat out.txt` | while
do
read x
echo $x
#re=200
j=0
if }" < "200" ]
then
echo $j
j=`expr $j... (2 Replies)
Discussion started by: rinku
2 Replies
4. UNIX Desktop Questions & Answers
OK... I'm fairly new to unix having the admin handed to me on a platter w/almost no training.
However, being a programmer, I do pick up things fairly easily, but this one is getting the best of me.
I have a unix server that runs multiple versions of the same ERP system, hand crafted for our... (1 Reply)
Discussion started by: chimodel
1 Replies
5. Shell Programming and Scripting
I need to find all the files that have group Read or Write permission or files that have user write permission.
This is what I have so far:
find . -exec ls -l {} \; | awk '/-...rw..w./ {print $1 " " $3 " " $4 " " $9}'
It shows me all files where group read = true, group write = true... (5 Replies)
Discussion started by: shunter63
5 Replies
6. IP Networking
Hi,
We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies
7. IP Networking
hi
am newbie to unix and socket programing
I am trying to figuring out syntax for read and write
to send data from server to client and client can read it
I have to send two integers
write(newsockfd,buffer,"%d %d",x,y,0) writing from client where x and y are two integers..
... (7 Replies)
Discussion started by: karthik1238
7 Replies
8. Shell Programming and Scripting
Hello Guys, How all are doing?
I have an issue in Unix and want help from all of you
I have a file in UNIX which it read by line by line , If at the end of line '0' is written the it should fetch that line into another file and change '0' to '1'
and If at the end of line '1' is written then it... (10 Replies)
Discussion started by: adisky123
10 Replies
9. Programming
Can someone help me to write this program in C in QNX?
Using the FIFO queues write a simple communication system consisting of programs write and read. The program write the parameters given strings enclosed in single quotes. These strings are written to the FIFO file. Reads the program read... (1 Reply)
Discussion started by: ebasse2
1 Replies
10. Shell Programming and Scripting
In the bash below the oldest folder in a directory is selected. If there are 3folders in the directory /home/cmccabe/Desktop/NGS/test and nothing is done to them (ie. no files deleted, renamed) then the bash correctly identifies f1 as the oldest. However, if something is done to the folder then... (4 Replies)
Discussion started by: cmccabe
4 Replies
LEARN ABOUT PHP
aio_write
AIO_WRITE(3) Linux Programmer's Manual AIO_WRITE(3)
NAME
aio_write - asynchronous write
SYNOPSIS
#include <aio.h>
int aio_write(struct aiocb *aiocbp);
Link with -lrt.
DESCRIPTION
The aio_write() function queues the I/O request described by the buffer pointed to by aiocbp. This function is the asynchronous analog of
write(2). The arguments of the call
write(fd, buf, count)
correspond (in order) to the fields aio_fildes, aio_buf, and aio_nbytes of the structure pointed to by aiocbp. (See aio(7) for a descrip-
tion of the aiocb structure.)
If O_APPEND is not set, the data is written starting at the absolute position aiocbp->aio_offset, regardless of the file offset. If
O_APPEND is set, data is written at the end of the file in the same order as aio_write() calls are made. After the call, the value of the
file offset is unspecified.
The "asynchronous" means that this call returns as soon as the request has been enqueued; the write may or may not have completed when the
call returns. One tests for completion using aio_error(3). The return status of a completed I/O operation can be obtained aio_return(3).
Asynchronous notification of I/O completion can be obtained by setting aiocbp->aio_sigevent appropriately; see sigevent(7) for details.
If _POSIX_PRIORITIZED_IO is defined, and this file supports it, then the asynchronous operation is submitted at a priority equal to that of
the calling process minus aiocbp->aio_reqprio.
The field aiocbp->aio_lio_opcode is ignored.
No data is written to a regular file beyond its maximum offset.
RETURN VALUE
On success, 0 is returned. On error, the request is not enqueued, -1 is returned, and errno is set appropriately. If an error is detected
only later, it will be reported via aio_return(3) (returns status -1) and aio_error(3) (error status--whatever one would have gotten in
errno, such as EBADF).
ERRORS
EAGAIN Out of resources.
EBADF aio_fildes is not a valid file descriptor open for writing.
EFBIG The file is a regular file, we want to write at least one byte, but the starting position is at or beyond the maximum offset for
this file.
EINVAL One or more of aio_offset, aio_reqprio, aio_nbytes are invalid.
ENOSYS aio_write() is not implemented.
VERSIONS
The aio_write() function is available since glibc 2.1.
ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7).
+------------+---------------+---------+
|Interface | Attribute | Value |
+------------+---------------+---------+
|aio_write() | Thread safety | MT-Safe |
+------------+---------------+---------+
CONFORMING TO
POSIX.1-2001, POSIX.1-2008.
NOTES
It is a good idea to zero out the control block before use. The control block must not be changed while the write operation is in
progress. The buffer area being written out must not be accessed during the operation or undefined results may occur. The memory areas
involved must remain valid.
Simultaneous I/O operations specifying the same aiocb structure produce undefined results.
SEE ALSO
aio_cancel(3), aio_error(3), aio_fsync(3), aio_read(3), aio_return(3), aio_suspend(3), lio_listio(3), aio(7)
COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the
latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
2017-09-15 AIO_WRITE(3)