Questions tagged [fcntl]

fcntl refers to a function that provides control over the open file referenced by a file descriptor

fcntl refers to a function that provides control over the open file referenced by a file descriptor.

234 questions
0
votes
1 answer

How to connect the old descriptor with the new descriptor?

Consider i have opened the file as hell.txt with the open() function. fd=open("hell.txt",O_RDONLY); then, consider it will return the descriptor as 4. and hi.txt already occupy the descriptor 3, so i want to connect the hell.txt file with 3…
Bhuvanesh
  • 1,269
  • 1
  • 15
  • 25
0
votes
1 answer

How to get console width without using ncurses?

What I need is only the console width, so it is better to not depend on another library that provides many other functions. In addition, the user of my library probably don't have ncurses dev headers installed; so if I remove the dependency on…
jiandingzhe
  • 1,881
  • 15
  • 35
0
votes
1 answer

How are ioctl() and/or fcntl() used for writing a non-blocking socket?

I am trying to learn how to write a non-blocking socket. Can anyone please explain that what roles do ioctl() and fcntl() play in this (i.e. what are the roles of file descriptors in creating a non-blocking socket. A code snippet as an example with…
Mac
  • 3
  • 3
0
votes
0 answers

Using fcntl() and fwrite() to write to a file remotely

I am having some problems, when trying to write to a file on a server. Different clients can perform read/write requests. I am using fcntl() to lock the file when a write request is made. However, when a process(client) obtains a lock and another…
0
votes
1 answer

What is the difference between Non blocking and Asynchronous socket

What is the difference between Non blocking and Asynchronous socket modes that we set using below calls. Case 1: int sockfd; // create_sock(sockfd); // init_sock(sockfd); fcntl(sockfd, F_SETFL, O_NONBLOCK); Case 2: int sockfd; //…
akure
  • 49
  • 1
  • 7
0
votes
1 answer

Get pid of the process which created the socket

How can i get pid of process which established a socket. I went through this PDF link, where he has mentioned Calling fcntl() with F_SETOWN and the pid of our process to tell the process that it is the owner of the socket.How can i get socket owner…
0
votes
1 answer

Make a stream read() blocking

What's the inverse of this? fcntl.fcntl(MyStream.fileno(), fcntl.F_SETFL, os.O_NONBLOCK) I've tried fcntl.fcntl(MyStream.fileno(), fcntl.F_SETFL, os.O_BLOCK) but it results in a AttributeError: 'module' object has no attribute 'O_BLOCK'. To give…
Basic
  • 26,321
  • 24
  • 115
  • 201
0
votes
1 answer

File r/w locking and unlink

I have following problem. I want to create a file system based session storage where each session data is stored in simple file named with session ids. I want following API: write(sid,data,timeout), read(sid,data,timeout), remove(sid) where…
Artyom
  • 31,019
  • 21
  • 127
  • 215
0
votes
1 answer

Forcefully remove fcntl locks from a different process

Is there any way I can remove fcntl byte range locks on a file from a process that did not lock these ranges? I have several processes that put byte range locks on files. What I basically need to come up with is an external tool that would help me…
Maksim Skurydzin
  • 10,301
  • 8
  • 40
  • 53
0
votes
1 answer

How to - sum of matrix elements using file lock (unix - C/C++)

I have an M[nxn] matrix and have to calculate the sum of the elements in the [n, n] point considering the following criteria: -randomly choose a row or a column ; -sum it's elements in the last element of that row or column and set the other…
Adorjan
  • 39
  • 9
0
votes
1 answer

When will fcntl in solaris return a value less then -1 for F_SETLKW

Fromt he Mannul of fcntl in solaris, Upon successful completion, value returned for F_SETLKW will be "Value other than -1". But Apache httpd 1.3.41 source code (http_main.c) check if the returned value is positive like: int ret; while ((ret =…
user166346
0
votes
1 answer

I have used below code to check single instance of replace.exe is running

I have used below code to check single instance of replace.exe is running. When i create replace.exe and run on windows, one more file with name replace(without any extension) of 0 kb size is getting created. I don't want that file to be created…
0
votes
1 answer

Does lseek work on file redirection?

Usually lseek doesn't work on stdin. But, what if I run my program like this: ./a.out < filename Now stdin is a file and not keyboard. Will lseek work there? Can I do lseek(0, -1, SEEK_CUR) and get the same effect like ungetc() ?
Sam
  • 1,842
  • 3
  • 19
  • 33
0
votes
0 answers

fcntl does not detect Bad file descriptor on socket fd

fcntl(sockfd,F_GETFD,0) doesn't detect a bad file descriptor whereas select on the same sock fd gives bad file descriptor error.
user1495948
  • 65
  • 2
  • 9
0
votes
1 answer

a flag of libev about ev_default_fork

I'm learning libev. But I don't understand about the ev_default_fork flag of ev_loop. Is this a question of close-on-exec? Like the FD_CLOEXEC fcntl() flag do? when I need to set the flag? Which case this flag is necessary? This a description of…
simon
  • 1
1 2 3
15
16