02-15-2011
What happens fwrite/fread at the same time?
Hello,
I have a question about what happens when I copy the file which is being written by another process on Solaris 9/SPARC, UFS file system.
in particular, I want to know what happens while some process is reading the file using fread or mmap, another process try to write something on the exactly same place where is read by other process.
in the situation described above, does fwrite causes error? or both system call suceeds?
If you know there is some document or specification defines about confliction of read/write/mmap, please tell me.
(sorry if my English or manner is not good, I've never been post a question in these kind of forums)
Thanks.
10 More Discussions You Might Find Interesting
1. Programming
Hi...
I am trying to read a binary data that have different types of messages of different lengths. I am using fread() but this functions needs the size and count to read the buffer from the file. I think this may cause that the buffer overlaps other messages.
Is there an alternative to read... (1 Reply)
Discussion started by: jlrodz
1 Replies
2. Programming
After my previous thread, I think I found out what causes the long delays.
I run this program on several Linux computers, and the sometimes (after the file with the arrays becomes big) the fwrite takes between 100 ms to 900 ms.
This is very bad for me, as I want a timer to halt each 30 ms.... ... (5 Replies)
Discussion started by: inna
5 Replies
3. Programming
Hi ,
I am running a C/C++ program on a solaris 5.8 machine. This parituclar application has a module which saves data to a file. The module uses fwrite() function to save data.
The fwrite function write about 500 MB of data to a file. The problem which I am facing is, the memory consumtion... (2 Replies)
Discussion started by: ajphaj
2 Replies
4. Programming
Code : function sSaveTFFile
.......................
iRetCode = link (caCurrentFilename, caBackupFilename);
if (iRetCode == -1)
{
ERR_MSG2(LOG_ALERT, "Can't move %s to %s", caCurrentFilename, caBackupFilename);
return(FAILURE);
}
iRetCode = unlink... (6 Replies)
Discussion started by: fermisoft
6 Replies
5. Programming
Hi All,
These are the two ways i tried to read file but i getting work with second one not with the first.
char buf; // Defining space for buf
ctrlfnum = fopen(filename_arr.control_fname,"r");
1) n = fread(buf,sizeof(buf),1,ctrlfnum); ============== (not works)
2) n =... (4 Replies)
Discussion started by: arunkumar_mca
4 Replies
6. Programming
Hi
I have an fwrite function in my C++ application. It is able to create the files in HP-UX.
cross is one structure
rec2 is another structure within cross.
fwrite_return = fwrite( &cross.rec2,
sizeof(cross.rec2),
... (14 Replies)
Discussion started by: rkraj
14 Replies
7. Programming
Hello All,
I tried to test a sample fread example to read a complete file
and the code is
#include <stdio.h>
#include <stdlib.h>
int main () {
FILE * pFile;
long lSize;
char * buffer;
size_t result;
pFile = fopen ( "test.xml" , "rb" );
if (pFile==NULL) {fputs ("File... (11 Replies)
Discussion started by: quintet
11 Replies
8. Programming
Hi,
my code is written in proC and it is in UNIX(AIX).I have written a small code for writing data into a binary file,but while writing my program is giving core dump.
Here Is my code----
fpWriteFile = fopen(WriteFileName,"wb+");
CHAR *recvgen;
recvgen = (char... (7 Replies)
Discussion started by: ajaysahoo
7 Replies
9. Programming
When fread is used twice, the second time it seems to overwrite the first time's output. Is there any way to clear fread's internal buffer after each use ?
char *FILEREAD(const char *FILENAME)
{
static char READBUFFER = "";
READBUFFER = '\0'; // try to solve the problem but this will not... (2 Replies)
Discussion started by: limmer
2 Replies
10. Programming
Hello,
I am trying to read a text file into linked list, but always got the first and last records wrong.
1) The problem looks related to the initialization of the node temp with malloc(), but could not figure it out. No error/warning at compiling, though.
2) The output file is empty,... (10 Replies)
Discussion started by: yifangt
10 Replies
FREAD(3) BSD Library Functions Manual FREAD(3)
NAME
fread, fwrite -- binary stream input/output
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <stdio.h>
size_t
fread(void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
size_t
fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
DESCRIPTION
The function fread() reads nitems objects, each size bytes long, from the stream pointed to by stream, storing them at the location given by
ptr.
The function fwrite() writes nitems objects, each size bytes long, to the stream pointed to by stream, obtaining them from the location given
by ptr.
RETURN VALUES
The functions fread() and fwrite() advance the file position indicator for the stream by the number of bytes read or written. They return
the number of objects read or written. If an error occurs, or the end-of-file is reached, the return value is a short object count (or
zero).
The function fread() does not distinguish between end-of-file and error; callers must use feof(3) and ferror(3) to determine which occurred.
The function fwrite() returns a value less than nitems only if a write error has occurred.
SEE ALSO
read(2), write(2)
STANDARDS
The functions fread() and fwrite() conform to ISO/IEC 9899:1990 (``ISO C90'').
BSD
March 8, 1994 BSD