10-26-2010
We have a homework forum for homework questions.
The simple answer is to call fdopen(file_descr, mode). File descriptors are only valid within a process, or in a child process. For linux check out sendfile.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I am trying to find a way to check the current status of a file. Such as some cron job processes are dependent on the completion of others. if a file is currently being accessed / modified or simply open state I will wait until it is done being processed before attempting the next process on that... (3 Replies)
Discussion started by: Gary Dunn
3 Replies
2. Programming
Hi,
I want to validate that a file is a socket file on Linux. I know I can do this using the S_ISSOCK macro, but I am not sure how to get the file descriptor for the socket file.
For example, I know that /tmp/mapping-foo is a socket file. In Python I can do something like this:
>>> import... (2 Replies)
Discussion started by: goon12
2 Replies
3. Shell Programming and Scripting
How to overwrite every time a particular portion of a file?
---------- Post updated at 02:16 PM ---------- Previous update was at 02:07 PM ----------
I have a file whose contents are something like:
Output of "apachectl fullstatus" command:
---------------------------------------------... (3 Replies)
Discussion started by: proactiveaditya
3 Replies
4. UNIX for Dummies Questions & Answers
hi....,
can anyone tell me what is the exact difference between file descriptor and file pointer...... and why file descriptor takes integer value???:confused: (10 Replies)
Discussion started by: jimmyuk
10 Replies
5. Linux
Long story short, there was some sort of corruption with my ide and the script I was working on has been over written with nothing (the file is blank now). The IDE doesn't store a back up from what I know (I'm using notepadd++ in wine lol I know I know I'm addictted to the nppftp sidebar and geany... (1 Reply)
Discussion started by: noPermissions
1 Replies
6. UNIX Desktop Questions & Answers
I have loads of files in different directories which I do miner changed on them and till now I have to create totally new directories for them, specially as I deal with a whole directory at once :wall::wall::wall::wall:
it creates such as mess really
e.g.
FILES="F1/*"
for X in $FILES
do... (2 Replies)
Discussion started by: A-V
2 Replies
7. Shell Programming and Scripting
I have a script, which runs through cronjob every night 9 PM. It is supposed to do following tasks --
1- Connect to ftp.testsite.com via user redtest
2- Fetch file red_bill.txt to my local server, where my script is residing.
3- Rename red_bill.txt to red_bill.V01.txt everyday on sftp server.... (4 Replies)
Discussion started by: solaris_1977
4 Replies
8. Shell Programming and Scripting
Hi, An application is transferring a file to linux system with same file name. As file is transferring with same name always file will be overwritten. In this case we want to know what times file was overwirtten like below.
Modify: 2014-05-12 00:52:01.000000000
Modify: 2014-05-12... (2 Replies)
Discussion started by: Satyak
2 Replies
9. Shell Programming and Scripting
hi
i have a file as in follwoing:
cat apple.txt
Apple is a fruit
But this fruit is costly
Now I used the sed command and i see output as in following
# sed 's/fruit/healthy &/' fruit.txt
Apple is a healthy fruit
But this healthy fruit is costly
#
sed works fine here. But... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies
10. Shell Programming and Scripting
Hello,
I have been working on script in which search and replace the multiple pattern.
1. update_params.sh read the multiple pattern from input file ParamMapping.txt(old_entry|New_entry) and passing this values one by one to change_text.sh
2. change_text.sh read... (0 Replies)
Discussion started by: ketanraut
0 Replies
fdopen(3C) fdopen(3C)
NAME
fdopen - associate a stream with a file descriptor
SYNOPSIS
#include <stdio.h>
FILE *fdopen(int fildes, const char *mode);
The fdopen() function associates a stream with a file descriptor fildes.
The mode argument is a character string having one of the following values:
r or rb Open a file for reading.
w or wb Open a file for writing.
a or ab Open a file for writing at end of
file.
r+, rb+ or r+b Open a file for update (reading and
writing).
w+, wb+ or w+b Open a file for update (reading and
writing).
a+, ab+ or a+b Open a file for update (reading and
writing) at end of file.
The meaning of these flags is exactly as specified for the fopen(3C) function, except that modes beginning with w do not cause truncation
of the file.
The mode of the stream must be allowed by the file access mode of the open file. The file position indicator associated with the new stream
is set to the position indicated by the file offset associated with the file descriptor.
The fdopen() function preserves the offset maximum previously set for the open file description corresponding to fildes.
The error and end-of-file indicators for the stream are cleared. The fdopen() function may cause the st_atime field of the underlying file
to be marked for update.
If fildes refers to a shared memory object, the result of the fdopen() function is unspecified.
Upon successful completion, fdopen() returns a pointer to a stream. Otherwise, a null pointer is returned and errno is set to indicate the
error.
The fdopen() function may fail and not set errno if there are no free stdio streams.
The fdopen() function may fail if:
EBADF The fildes argument is not a valid file descriptor.
EINVAL The mode argument is not a valid mode.
EMFILE {FOPEN_MAX} streams are currently open in the calling process.
{STREAM_MAX} streams are currently open in the calling process.
ENOMEM There is insufficient space to allocate a buffer.
USAGE
A process is allowed to have at least {FOPEN_MAX} stdio streams open at a time. For 32-bit applications, however, the underlying ABIs for-
merly required that no file descriptor used to access the file underlying a stdio stream have a value greater than 255. To maintain binary
compatibility with earlier Solaris releases, this limit still constrains 32-bit applications.
File descriptors are obtained from calls like open(2), dup(2), creat(2) or pipe(2), which open files but do not return streams. Streams are
necessary input for almost all of the standard I/O library functions.
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
creat(2), dup(2), open(2), pipe(2), fclose(3C), fopen(3C), attributes(5), standards(5)
18 May 2005 fdopen(3C)