descriptor « Development « C File Q&A

Home
C File Q&A
1.array
2.binary
3.delete
4.Development
5.directory
6.fgets
7.fopen
8.fprintf
9.fscanf
10.fwrite
11.header
12.include
13.input
14.LINE
15.linux
16.open
17.output
18.pointer
19.read
20.size
21.string
22.struct
23.Text
24.windows
25.write
C File Q&A » Development » descriptor 

1. File Descriptor Assignment in C    stackoverflow.com

When sockets are created or files are opened/created in C, is the file descriptor that's assigned to the socket/file guaranteed to be the lowest-valued descriptor available? What does the C ...

2. Is there a need to close file descriptors before exit?    stackoverflow.com

Of course, the immediate answer for most situations is "yes", and I am a firm believer that a process should correctly cleanup any resources it has allocated, but what I have ...

3. Passing a file descriptor opened in C to a tcl interpreter for use    stackoverflow.com

I have a C program in which I create a tcl interpreter. I then open a file in the C program and want to pass it onto the tcl interpreter so ...

4. How to get file descriptor of buffer in memory?    stackoverflow.com

If I have a buffer which contains the data of a file, how can I get a file descriptor from it? This is a question derived from how to untar file ...

5. question on changing file descriptor number in c    stackoverflow.com

my question is how would I change the program below so that it takes a file descriptor number on the command line rather than a file name? Any help would ...

6. Bad File descriptor    stackoverflow.com

Does anyone see a problem with this, its not working saying bad file descriptor not sure why?

pipe(pipefd[0]);
if ((opid = fork()) == 0) {
     dup2(pipefd[0][1],1);/*send to output*/
 ...

7. Multiple file descriptors to the same file, C    stackoverflow.com

I have a multithreaded application that is opening and reading the same file (not writing). I am opening a different file descriptor for each thread (but they all point to the ...

8. How to check if a file descriptor has any data available?    stackoverflow.com

I'd like to know if a fd has data available for reading. I have tried ioctl with FIONREAD but that results in a "Operation not supported error". Any ideas?

9. create backup file descriptor?    stackoverflow.com

  stdinBackup = 4;
  dup2(0, stdinBackup);
Currently I am doing the above to 'backup' stdin so that it can be restored from backup later after it has been redirected somewhere ...

10. Is O_NONBLOCK being set a property of the file descriptor or underlying file?    stackoverflow.com

From what I have been reading on The Open Group website on fcntl, open, read, and write, I get the impression that whether ...

11. How to execute a program from file descriptor?    stackoverflow.com

I need to execute a file when I only know the descriptor. It is also possible that there are no links to the file so finding out the name somehow is ...

12. How to determine if a file descriptor is seekable?    stackoverflow.com

Is there any portable way (on POSIX systems) to determine if a file descriptor is seekable? My thought is to use lseek(fd, 0, SEEK_CUR); and check if the return value is ...

13. What is bad file descriptor in c?    stackoverflow.com

This is my code of function that wants to read file:

int sendByByte(int filed,int sockfd,int filesize)
{
 int i=0;
 int sent=0;
 char buf[BUFSIZE];
 while(i<filesize)
 {
  printf("fd is : %d\n",filed);
  printf("i: %d\n",i);
 ...

14. Can we obtain a file descriptor for a semaphore or condition variable?    stackoverflow.com

I have an implementation of a bi-directional message channel which, to reduce overhead, I implemented as a couple of circular buffers of messages. To write from one end to the other ...

15. c strcpy a file descriptor    stackoverflow.com

I have a question with strcpy() function. What I am trying to do is the user enters a file name and I basicly open the file, gets contents and create copy ...

16. Unix Shell Implementing Cat in C - File Descriptor Issue    stackoverflow.com

I've about got my practice implementation of a Unix shell done, except I'm having an issue with implementing cat when its output is to a file; IE: cat foo.txt > bar.txt ...

17. C: dup2() before execv    stackoverflow.com

For a homework assignment I have to write a basic shell including redirection. The program uses readline to prompt for input, parses the input string, and breaks it down into the ...

18. Do not want a parent and its child process to share the same file descriptor table    stackoverflow.com

I open a file in program A. Its file descriptor is 3. Using fork followed by an execve I execute another program B, where I immediately open another file. This files ...

19. Create a file descriptor    stackoverflow.com

I want to create a file descriptor in C whose value i will specify in code. I have a integer variable which specifies the value of file descriptor to be created. For ...

20. Bad file descriptor    stackoverflow.com

I'm learning about file descriptors and I wrote this code:

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

int fdrd, fdwr, fdwt;
char c;

main (int argc, char *argv[]) {

    if((fdwt = open("output", O_CREAT, 0777)) ...

21. How would I assign multiple MMAP's from single file descriptor?    stackoverflow.com

So, for my final year project, I'm using Video4Linux2 to pull YUV420 images from a camera, parse them through to x264 (which uses these images natively), and then send the encoded ...

22. Why is fileno failing to return a valid descriptor?    stackoverflow.com

I'm opening a stream with funopen

FILE *fin = funopen(cookie, readfn, NULL, NULL, closefn);
if (fin == NULL)
{
    handle_error();
    return -1;
}
int fdin = fileno(fin);
The call to funopen ...

23. Pass File Descriptor - Execve (typecast)    stackoverflow.com

I am wondering how I can pass a file descriptor thru the execve command and then access it on the other side. I know that I can use dup2 to ...

24. Bad File Descriptor on a serial port    stackoverflow.com

I'm implementing a simple protocol to do file transfer between 2 PC's over serial port and I'm getting a weird error. On the main I call a function "llopen":

int 
llopen(int ...

25. Is it possible to keep stdout intact in one process but still have a pipe to a second process?    stackoverflow.com

I am trying to make a logger for a program. For that reason I am having a second child process that is getting the parent's stdout via a pipe and using ...

26. Detecting if a file descriptor is closed    bytes.com

My memory is really fuzzy on this topic, but I think I've accomplished something like this in the past by setting a timer, then calling read(). Then if the timer expires you get an interrupt, which makes the read fail, setting errno appropriately. That way you can just start the read and if the socket is closed you'll get that error ...

27. Checking if a file descriptor is valid    bytes.com

By file descriptor do you mean a C language FILE handle or one of those unix style integers used for IO? (I'm not sure what windows uses in this case.) In C++, there is a good and is_open method for checking valid streams. One technique is to just do what you really want to do with the IO channel (i.e read, ...

28. Posix mqueue bad file descriptor.    cboard.cprogramming.com

Hi, I trying to make a program with one thread sending a message to a message queue and the other receiving and printing it. This is what I've written so far: Code: #include #include #include #include #include #include #include #include #include #define MQUEUE_NAME "/mqueue" pthread_t send_thread, receive_thread; pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; struct ...

29. file descriptor redirection    cboard.cprogramming.com

30. why wrong file descriptor ??    cboard.cprogramming.com

hi friends, its all code, but not getting why it is telling wrong descriptor. Code: 1 //redirecting output of ls -l command to wc, with help of tmp file 2 3 #include 4 #include 5 6 7 void main() 8 { 9 int fd ; 10 switch(fork()) 11 { 12 default : break ; 13 14 case -1 : fprintf(stderr, "system ...

31. Bad file descriptor upon connect    forums.devshed.com

struct hostent *he; struct sockaddr_in server; int sockfd; /* resolve localhost to an IP (should be 127.0.0.1) */ if ((he = gethostbyname("nems")) == NULL) { puts("error resolving hostname.."); exit(1); } /* * copy the network address part of the structure to the * sockaddr_in structure which is passed to connect() */ memcpy(&server.sin_addr, he->h_addr_list[0], he->h_length); server.sin_family = AF_INET; server.sin_port = htons(1514); /* ...

32. How to get a file offset position from a file descriptor?    forums.devshed.com

I am using the open() function to get a file descriptor for a certain file, and I want to get the current file position given this file descriptor. Is there any way to access the file position else than using the tell() function as it's not supported in the environment I am using. Regards, Rami Henein.

33. File descriptor mess ..    forums.devshed.com

fdDBG = NULL; if (argc > 1 ) { int i; for (i=0 ; i< argc; i++) { if ( strncmp(argv[i],"-f",2) == 0 ) { i=i+1; fdDBG = fopen(argv[i],"w"); if (fdDBG == NULL) { fdDBG = fdopen(2,"a"); #ifdef DEBUG pthread_mutex_lock(&dbg_mutex); fprintf(fdDBG,"%s Unable to open debug message file %s\nUsing stderr instead.\n",oStr,argv[i] ); pthread_mutex_unlock(&dbg_mutex); #endif } } } } if (fdDBG == NULL) ...

34. how to get an available file descriptor?    forums.devshed.com

Hi, I'm facing the following problem: I'm writing some code in a server-type environment. The server, when it gets a new connection, maps the socket file descriptor of the connecting client to stdin and stdout using dup2(). In my function, I want to map stdin and stdout to a different file descriptor (a temporary file) while not losing the client's file ...

35. Bad File descriptor error on strcat    forums.devshed.com

36. client file descriptor    tek-tips.com

Helloin socket programming, how can I get the file decriptor for a remote client? Let me elucidateI have a server, two clients are suppose to connect to that server and pass message between them. I am using UDP. From a client, the message goes to the server and the server sends the message to the other client. The clients instantiates new ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.