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
1 answer

Shared mmap co-ordination using fcntl locks?

When using mmap() for shared memory (from Linux, or other UNIX-like systems) is it possible (and portable) to use fcntl() (or flock() or lockf() functions) to co-ordinate access to the mapping? Responses to this SO question seems to suggest that it…
Jim Dennis
  • 17,054
  • 13
  • 68
  • 116
3
votes
1 answer

Why don't I see deadlock (EDEADLK) when several processes lock the same fd with F_SETLKW?

I need to properly handle EDEADLK. In my program I see that both children wait until parent sleep and, and then they apply the lock and right away they leave it. Sorry for my mistakes, I am a Spanish student. int main(){ pid_t childpid,…
Jorge M
  • 33
  • 1
  • 3
3
votes
0 answers

Android does not support robust futexes, so how to implement a robust mutex?

I found the pthread.h in android ndk does not include robust futexes functions, so what should I do if I want to access a shared memory(mmap) between multiple processes? PS: Now, I use std::shared_mutex + fcntl, which the shared_mutex is for thread,…
alpha
  • 1,228
  • 1
  • 11
  • 26
3
votes
3 answers

How can I read and write from files using the headers fcntl.h and unistd.h?

I'm trying to learn how to use the header files and . I have created a small example to test the workings of their procedures, but it didn't work as expected. Here is my code: #include #include int main() { …
Rontogiannis Aristofanis
  • 8,883
  • 8
  • 41
  • 58
2
votes
3 answers

No manual entry for fcntl problem

When I use `man fcntl' got the message: No manual entry for fcntl which the pkg is needed to install? ps. I use debian.
qrtt1
  • 7,746
  • 8
  • 42
  • 62
2
votes
1 answer

How can I set a pipe to O_NONBLOCK perl

This works fine: #!/usr/bin/perl -w # #pipe2 - use pipe and fork so child can send to parent use IO::Handle; pipe(READER, WRITER); WRITER->autoflush(1); if ($pid = fork) { close WRITER; chomp($line = ); print "Parent Pid…
user1424074
  • 137
  • 1
  • 7
2
votes
1 answer

Docker and fcntl OSError Errno 22 Invalid argument

I've encountered a weird problem and I do not know how to proceed. I have docker 18.09.2, build 6247962 on a VMware ESXi 6.5 virtual machine running Ubuntu 18.04. I have docker 19.03.3, build a872fc2f86 on a Azure virtual machine running Ubuntu…
Lewis M
  • 550
  • 3
  • 7
2
votes
1 answer

Implementing lseek in xv6

First off I need to say it's completely possible I'm missing something. My assignment is to essentially implement 'fprintf'. Now while appending to the file isn't required, I like to go above and beyond. My issue is, I can't find a definition for…
Flacarile
  • 69
  • 5
2
votes
5 answers

No module named fcntl

I am trying to execute this method with IronPython on .NET 4.0 using IronPython 2.7. i am using Windows 7 import os import re import nltk import urllib import xapian import sys def getData(url): try: html = urllib.urlopen(url) …
michelle
  • 2,759
  • 4
  • 31
  • 46
2
votes
3 answers

How to tell if FILE* is referring to a directory?

I just discovered that a FILE* can not only refer to a regular file, but also to a directory. If the latter is the case, fread will fail with errno set to 21 (Is a directory). Minimal repro can be tested here #include #include…
Tobi
  • 2,591
  • 15
  • 34
2
votes
1 answer

Why can't I create read-only, shared mappings after setting F_SEAL_WRITE?

After doing fcntl(memfd, F_ADD_SEALS, F_SEAL_WRITE);, calls like mmap(NULL, 4096, PROT_READ, MAP_SHARED, memfd, 0); fail with error EPERM. Based on man 2 fcntl, my understanding of F_SEAL_WRITE is that it only prevents writable, shared mappings.…
2
votes
3 answers

Error with "mlflow ui" when trying to run it on MS Windows

When I run mlflow ui the following error occurred: Traceback (most recent call last): File "c:\anaconda3\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:\anaconda3\lib\runpy.py", line 85, in _run_code …
Tavakoli
  • 1,303
  • 3
  • 18
  • 36
2
votes
1 answer

Unable to read file contents into buffer using read()

Following is a sample code compiled using GNU compiler (g++ command) on an Ubuntu OS 16.04: #include #include #include #include int main() { char* pBuffer; char* storedfilepath…
vedant gala
  • 428
  • 3
  • 18
2
votes
1 answer

fcntl F_GETLK always returns F_UNLCK

I am trying to understand POSIX file-region locks in C. The program below is really simple, sets the lock to F_WRLCK and then gets locks. There is no errors during opening/setting lock. Unfortunatelly it's always returning F_UNLCK. Where is the…
Wojtek338
  • 43
  • 4
2
votes
2 answers

Write magnetic tape end of record linux

Task is create two record with different sizes within one file entry. I'm using python 3.4.5 for testing: import fcntl import os import struct MTIOCTOP = 0x40086d01 # refer to mtio.h MTSETBLK = 20 fh = os.open('/dev/st2', os.O_WRONLY…