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
3
votes
2 answers

Why is the c function `open` ~4x slower on MacOS vs. an Ubuntu VM on the same machine?

Why is MacOS ~4x slower to open files than an Ubuntu VM on the same machine here? A MWE using similar settings to the code this behavior was discovered on #include #include #include int main() { struct timespec…
Ian
  • 1,427
  • 1
  • 15
  • 27
3
votes
1 answer

How to write EOF markers on Magnetic Tape - Python

I have searched a great deal on the web and I am unable to find a way to write an EOF marker on a magnetic tape in Python. I have the below code (using Python via fcntl.ioctl) which writes records but after each os.write it does not write an EOF but…
Magic Mick
  • 1,475
  • 1
  • 21
  • 32
3
votes
0 answers

Why doesn't O_CLOEXEC/FD_CLOEXEC flag work?

I have a parent process having some children which don't need the FIFO descriptor opened by the parent before forking. I have tried to do the following approaches that fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); after opening the fd. fd =…
3
votes
2 answers

flock() vs. fcntl() semantics in glibc

Related: one, two It's stated that flock() (BSD-locks) and fcntl() (POSIX record-level locks) gives the user incompatible semantics, particularly, in regards of lock release. However, in glibc flock() is implemented in terms of POSIX fcntl(). (I…
DimG
  • 1,641
  • 1
  • 16
  • 23
3
votes
0 answers

Explain fst_posmode, difference between F_PEOFPOSMODE and F_VOLPOSMODE?

Header file: /* Position Modes (fst_posmode) for F_PREALLOCATE */ #define F_PEOFPOSMODE 3 /* Make it past all of the SEEK pos modes so that */ /* we can keep them in sync should we desire */ #define F_VOLPOSMODE 4 …
Karl
  • 665
  • 4
  • 19
3
votes
1 answer

How to catch file mode?

I have to catch modes below: "rb", "r+b" and "wb". I tried to execute code (compiled) of this: #include #include #include #include int main() { FILE *file = fopen("data.bin", "r"); if (!file){ …
Антон
  • 191
  • 1
  • 1
  • 9
3
votes
1 answer

MACOSX (BSD) equivalent for F_NOTIFY flag for fcntl() function

Does anybody know equivalent for F_NOTIFY flag for fcntl function in a BSD based system? This flag allows you to receive notifications about file events (for example file opened, file closed, bytes written to file, bytes read from file). This flag…
Vlad
  • 2,090
  • 3
  • 21
  • 37
3
votes
0 answers

python: Terminal input, echo all except newline, and handle backspace?

I'm trying to write a function in Python-3.x which will prompt the user to enter characters from the keyboard. I want all characters to be echoed normally except for the final newline, which terminates the input. The following function does this…
HippoMan
  • 2,119
  • 2
  • 25
  • 48
3
votes
1 answer

What is full name of fcntl Unix/Linux system call

Man page of fcntl tell its used for manipulating file descriptors. But this name is not easy to remember. Knowing its full name will help in remember this system call name and its use. I tried to find on internet but could not get anything except…
Alok
  • 7,734
  • 8
  • 55
  • 100
3
votes
1 answer

Difference between select() and fcntl()

The way I understand it - we can use fctnl to mark a file descriptor as non-blocking, so whenever we call any blocking operation on that file descriptor, it would error and modify errno to indicate that the file descriptor isn't ready yet. The…
Kid Coder
  • 173
  • 1
  • 5
3
votes
0 answers

Xvfb virtual display error, no module named fcntl

Im trying to make a virtual display for a splinter script. When i runi get the error code "ImportError: No module named 'fcntl'" from splinter import Browser from xvfbwrapper import Xvfb vdisplay = Xvfb(width=1280,…
Jaypaque
  • 59
  • 8
3
votes
0 answers

Why does my program not populate the array with pixel values?

I'm working with a Lepton Thermal Camera Breakout Board and trying to read in pixel values using this simple python program: import numpy as np import cv2 from pylepton import Lepton with Lepton("/dev/spidev0.0") as l: a,_ =…
Angel Lockhart
  • 157
  • 1
  • 2
  • 11
3
votes
1 answer

Utility that helps in file locking - expert tips wanted

I've written a subclass of file that a) provides methods to conveniently lock it (using fcntl, so it only supports unix, which is however OK for me atm) and b) when reading or writing asserts that the file is appropriately locked. Now I'm not an…
Marian
  • 5,817
  • 2
  • 18
  • 21
3
votes
2 answers

Problems compiliing c++ code using cygwin

I am trying to compile some source code in cygwin (in windows 7) and get the following error when I run the make file g++ -DHAVE_CONFIG_H -I. -I.. -I.. -Wall -Wextra -Werror -g -O2 -MT libcommon_a Fcntl.o -MD -MP -MF .deps/libcommon_a-Fcntl.Tpo…
user343403
  • 31
  • 2
3
votes
0 answers

python ioctl creating ifreq struct

I am very new to system programming. I am trying to query some NIC information using Python with ioctl, I easily got the code but having some difficulty in understanding Python code to get the ip address nic = "eth1" # Create socket object sock =…
karthik
  • 305
  • 3
  • 10