fcntl Questions
2
I have to catch modes below:
"rb", "r+b" and "wb".
I tried to execute code (compiled) of this:
#include <stdio.h>
#include <sys/types.h>
#include <sys/s...
5
Solved
How can I get the serial number of a hard disk drive using Python on Linux?
I would like to use a Python module to do that instead of running an external program such as hdparm. Perhaps using the ...
Clerc asked 16/11, 2010 at 11:9
3
Solved
If a process give a file a write lock and then it spawn a child process, is lock inherited by the child process? If yes, then there is 2 process have the write lock, I learned that there is only 1 ...
1
When I create socket on Linux, it's possible to specify the flag O_CLOEXEC on creation time:
auto fd = socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0);
So there is no way, that some other thread wi...
1
Solved
My module depends on the Fcntl module (https://github.com/manchicken/perl6-Fcntl), which hasn't been updated in a long time and is broken. However, there's a fork (https://github.com/jonathanstowe/...
2
Solved
I mean to use fdopen
FILE *fdopen(int fd, const char *mode);
In man pages, it is stated that "The mode of the stream (one of the values "r", "r+", "w", "w+", "a", "a+") must be compatible with t...
Stephniestepladder asked 20/5, 2020 at 9:15
1
Solved
I am dealing with file status flags.
Among test I performed, I found
#include <stdio.h>
#include "fcntl.h"
int main() {
const int flag = O_RDONLY;
printf( "*** Flag O_RDONLY = %5d\n", fla...
Galvanism asked 20/5, 2020 at 22:1
2
Solved
I'm looking for a way to interrupt an accept() call on a blocking socket. Using signals is not an option, as this is meant to be in a library and I don't want to clutter the user signals. Using sel...
2
Solved
It seems GLIBC 2.28 (released August 2018) made a fairly aggressive change to fcntl. The definition was changed in <fcntl.h> to no longer be an external function, but a #define to fcntl64.
T...
Cleaves asked 20/10, 2019 at 12:23
7
Solved
On a Debian-based OS (Ubuntu, Debian Squeeze), I'm using Python (2.7, 3.2) fcntl to lock a file. As I understand from what I read, fnctl.flock locks a file in a way, that an exception will be throw...
3
Solved
Scenario: I have many processes running that need to fetch files over the net. If the file is already downloaded, I want it cached on disk. If another process is downloading the file, block until i...
1
Solved
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 f...
Inhospitality asked 27/11, 2017 at 17:54
2
Solved
While trying to use fcntl() with command F_GETFL and F_SETFL, I got some questions:
Why the flag returned by fcntl(fd, F_GETFL) only include a subset of bits of what I set when open file? Does it...
1
Prior warning: I'm hacking around here out of curiosity. I have no specific reason to do what I'm doing below!
Below is done on Python 2.7.13 on MacOS 10.12.5
I was hacking around with python and...
Boucher asked 6/7, 2017 at 12:4
1
Solved
1
Solved
I have a file results.txt on a server which is accessed by multiple VMs through NFS. A process runs on each of these VMs which reads the results.txt file and modifies it. If two processes, A and B,...
Needham asked 4/6, 2016 at 19:3
2
Solved
I have included following headers:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#...
2
I am starting serial port programming in Linux. After reading several examples on the web, I don't understand exact effect of fcntl(fd, F_SETFL, 0)? It is clearing bits, but what flags does it affe...
Sapphire asked 22/1, 2016 at 9:55
1
I have read enough posts on stackoverflow regarding the difference between flock/lockf/fcntl but I am unable to answer the below observation:
>>> import fcntl
>>> a = open('/tmp/l...
Eulaeulachon asked 12/2, 2015 at 5:50
2
Solved
I have the following code where I want to check if the file is locked or not. If not then I want to write to it. I am running this code by running them simultaneously on two terminals but I always ...
1
Solved
I've added code to a Python package (brian2) that places an exclusive lock on a file to prevent a race condition. However, because this code includes calls to fcntl, it does not work on Windows. Is...
3
Solved
I have a sample program:
int main()
{
const char* fn = "/tmp/tmpfifo";
int i = mkfifo(fn, 0666);
int fd = open(fn, O_RDONLY | O_NONBLOCK);
int flags = fcntl(fd, F_GETFL);
flags &= ~O_NONB...
Windblown asked 12/4, 2015 at 7:59
3
Following an example on resetting a serial port in Linux I wanted to translate the following snippet
fd = open(filename, O_WRONLY);
ioctl(fd, USBDEVFS_RESET, 0);
close(fd);
into valid python cod...
Abomb asked 31/1, 2013 at 12:59
3
Solved
I try to set O_CLOEXEC flag using open() and have no sucess.
Consider the following microtest:
#include <stdio.h>
#include <fcntl.h>
int main() {
int fd = open("test.c", O_RDONLY | ...
Interne asked 19/8, 2013 at 3:38
2
Solved
I have a C++ program that locks files using POSIX advisory locks. That is, it uses the POSIX fcntl system call for lock operations. I want a Java program to interoperate with that C++ program, so I...
Sorcim asked 9/5, 2014 at 10:30
1 Next >
© 2022 - 2024 — McMap. All rights reserved.