Questions tagged [system-calls]

Questions concerning the details of how a program uses system calls to interact with the kernel API, what calls are available, how they work etc.

Filter by
Sorted by
Tagged with
0 votes
1 answer
48 views

Where does the signal that causes EINTR come from?

I Understand that EINTR is an error which so-called interruptible system calls may return. My question is where does the signal that causes EINTR come from? I faced this quite often when using fnctl ...
chewing gum's user avatar
0 votes
0 answers
17 views

Issue with open syscall in /tmp folder with uid 0 [duplicate]

I have conducted a small test which raised an issue i could not figure out. Create file in /tmp named what as shell user (uid 1000), then make it 0666 (rw-rw-rw-) Try to call open with uid 0 (root) ...
TOK's user avatar
  • 1
0 votes
2 answers
74 views

man syscalls is missing in arch linux

I just can't find it. I've installed linux-docs with sudo pacman -S linux-docs but still man syscalls does not work.
Corel's user avatar
  • 103
2 votes
1 answer
180 views

Debugging strange EACCES (Permission denied) permission error

I have a symlink to a world-readable file that a c program is being unable to read. redshift is supposed to pick up configuration from $HOME/.config/redshift/redsihft.conf automatically, but it wasn't....
user84207's user avatar
  • 871
3 votes
1 answer
233 views

Man pages, syscalls, and libc

Why is epoll_create not listed as a library function (man pages, section 3), but accept is? While both functions are provided by libc and both refers to kernel syscalls? I know that "why" ...
ABu's user avatar
  • 556
0 votes
0 answers
33 views

Why: error: implicit declaration of function 'sys_close'?

I am trying to install the latest NVIDIA driver in Debian 12; part of the process involves building some kernel modules. Most of these compile without error, but it fails near then end (around 96%, ...
j4nd3r53n's user avatar
  • 591
0 votes
1 answer
52 views

Terminal syscalls in Assembly

I would like to write a chess engine for Linux. It will be in pure X64 Assembly language without any C/C++ or any other high level languages external libraries. It will run in full screen text/console/...
Danny Cohen's user avatar
0 votes
0 answers
50 views

Linux: Do userland threads have a higher priority when performing system calls?

From what I understand, Linux features kernel preemption, meaning that a thread executing a system call can be preempted and rescheduled to run on the next epoch. This leads me to wonder if a thread ...
exliontamer's user avatar
0 votes
0 answers
66 views

Parallelism and I/O in Linux

I'm a bit confused about how the Linux kernel handles parallelism during I/O operations (if it handles it at all). I assume it can concurrently operate on file descriptors, but does it achieve ...
asnail's user avatar
  • 1
0 votes
2 answers
149 views

exec() system call in Linux

Accoding to this link, we need to terminate the list of argumnets by a null pointer. This is stated as : The list of arguments must be terminated by a null pointer. My question is why we need to ...
John adams's user avatar
11 votes
3 answers
2k views

Why isn't something like compound syscalls implemented?

Syscalls (system calls) cause some performance penalty due to the isolation between kernel and user space. Therefore, it sounds like a good idea to reduce syscalls. So what I thought is, that we could ...
drahnoel's user avatar
  • 333
3 votes
0 answers
135 views

Lower system call perfermance on aarch64 vs. x86-64

Does anyone know why system calls take longer to execute on 64-bit ARM (aarch64) compared to 64-bit Intel CPUs (x86-64)? Please see below my benchmarking setup. 64-bit ARM CPU: Ampere Altra Q80-30, ...
Dumi Loghin's user avatar
0 votes
0 answers
106 views

Convention of using #includes for the header files for using a system call provided by linux kernel into my custom system call

I am trying to design a system call of my own. And as per need, I am considering using a system call already provided by linux kernel. Below is the program : #include <linux/kernel.h> #include &...
Abhishek Ghosh's user avatar
9 votes
1 answer
4k views

Why can Wine convert Windows systemcall to Linux systemcall?

As long as the architectures are the same, it is no wonder that Windows .exe file can run on the Linux system (if it is properly loaded on the RAM). But systemcalls of Linux and Windows are entirely ...
user356126's user avatar
0 votes
1 answer
57 views

syscall accept4() returns an invalid value

I created a program similar to "strace" which is able to log the syscalls. Also I installed a webserver and watched the syscalls from 'strace' and from my program and compared them. For each ...
user554179's user avatar
2 votes
0 answers
18 views

system call poll for /tmp/.X11-unix/X1 takes too long

I have a GUI program that takes too long to respond, so I used strace -T to report all its system calls. I find the reason causing the program slow is poll costs too much time. For example, the ...
Simon's user avatar
  • 170
0 votes
0 answers
176 views

Why am I receiving a POLLERR on pooling a socket?

I am facing strange DNS errors, so I wrote a small C program to do some tests using the getaddrinfo(3) function. I saw that sometimes, on polling the socket to read the response, I got a POLLERR error ...
Jesús Ángel's user avatar
2 votes
1 answer
48 views

How do I insert my own lib to other binaries in Linux?

My goal is developing a tool for educational purposes which logs commands on a system. Until now have found primitive ways to do this but all these ways can be easily bypassed so I had this idea to ...
Jugert Mucoimaj's user avatar
2 votes
0 answers
288 views

How to get the current cgroup ID from C/C++?

The eBPF helper functions define bpf_get_current_cgroup_id for eBPF programs, which does the obvious thing u64 bpf_get_current_cgroup_id(void) Return A 64-bit integer containing the current ...
user547386's user avatar
3 votes
1 answer
2k views

Cannot write into /sys/power/mem_sleep in Fedora 36

Since I failed to find a way to tell systemctl to go to sleep in a one-time specified mode (see previous question), I decided to write some script to change whether the system goes to sleep in shallow ...
Silmathoron's user avatar
1 vote
1 answer
201 views

How can I efficiently read entries in a directory?

I would like my program to efficiently detect if a file was added to a directory between two invocations. That analysis might block user input (this would be for the fish shell), so I want it to run ...
Narrateur du chaos's user avatar
0 votes
1 answer
792 views

Get executable name in syscall?

So I am writing a system call in Linux. I want to print a message that looks like printk(KERN_DEBUG "PROC_DEBUG [%s, %s]: %s", executable, current->pid, message); Where executable is the ...
TheIncrediblyStupidOne's user avatar
9 votes
1 answer
493 views

What happened to llseek and e2fsck?

lseek man page: When users complained about data loss caused by a miscompilation of e2fsck(8), glibc 2.1.3 added the link-time warning "the llseek function may be dangerous; use `lseek64 ...
user3528438's user avatar
2 votes
1 answer
337 views

Why do syscalls not accept userspace callback functions?

This question is an extension of why do we need to pass buffers to system calls in order to have information returned? Why can't system calls allocate the buffer internally? since memory ...
Isaac's user avatar
  • 23
1 vote
1 answer
348 views

How are system call functions linked to an executable?

Say I write a non-sensical program that features a single system call, open: #include <fcntl.h> void main() { int hi = open("does not exist", 0); } When I compile the program ...
Izzo's user avatar
  • 999
1 vote
3 answers
86 views

How to detect when a terminal emulator closes from an orphaned process

I have a command line utility that spawns a daemon process which then becomes orphaned. How can I make the daemon exit along with the terminal emulator?
Rillian Grant's user avatar
8 votes
5 answers
2k views

What is difference between sleep and NOP in depth?

I am trying to learn operating system concepts. Here is two simple python code: while True: pass and this one: from time import sleep while True: sleep(0.00000001) Question: Why when running ...
Mojtaba Kamyabi's user avatar
1 vote
0 answers
65 views

Under what conditions are unix (Mac OS ) sytem calls restarted after getting interrupted by a signal ? What do the man page mean by "calls committed"?

I'm reading a book on unix systems and I'm at the part where signals are discussed. I'm a bit confused when it comes to what happens when a system call is running and a signal is received. It says ...
user529815's user avatar
1 vote
1 answer
232 views

Why is the linux system call interface architecture-dependent?

So one thing I'm not clear on is why transitioning from user space to kernel space is architecture-dependent. For example, the linux kernel v5.4 code for system calls entering kernel space is ...
user49404's user avatar
  • 181
2 votes
0 answers
96 views

What is the complete list of file functions equivalent to the "strace -e file" options?

According to man strace the -e file option traces all syscalls which take a file name as an argument. What is the whole set? %file file Trace all system calls which take a file ...
guronanak's user avatar
-1 votes
1 answer
280 views

Can the stdout (1) file descriptor be re-used after closing?

I first call close(1) and then later open a file using open() syscall. Is it possible that open() returns 1 because it will use the lowest free file descriptor? I have read that open() uses the lowest ...
zomega's user avatar
  • 873
1 vote
2 answers
498 views

why do we need to pass buffers to system calls in order to have information returned? Why can't system calls allocate the buffer internally?

I'm reading TLPI, and in section 4.4: System calls don’t allocate memory for buffers that are used to return information to the caller. Instead, we must pass a pointer to a previously allocated ...
sudeepdino008's user avatar
1 vote
2 answers
359 views

X11: what system calls does X.Org Server use to realize GUI environment?

Recently, I am studying Xlib and come to have a question: What system calls (API's) does X.Org Server use to realize GUI environment. In terms of output, what system calls enable us to draw windows (...
user356126's user avatar
1 vote
1 answer
449 views

Timing system call with ltrace: Adding `syscall` + `clock_gettime`?

I'm looking for some clarity in terms of the system calls. I tried avoiding the vDSO by calling a system call clock_gettime directly. Here is a snippet of a program named sys_clock_gettime. int clock =...
Xavier Merino's user avatar
7 votes
4 answers
3k views

Using System calls directly

I have a big confusion regarding the system calls in OS. According to the book "operating systems concepts 9th ", it is mentioned (in page 63) that : Most programmers never see this level ...
AAA's user avatar
  • 207
0 votes
0 answers
77 views

Is there a darwin (arm64) equivalent of `O_PATH` for open?

I want to get the file descriptor without opening the file which can be attained by using the O_PATH flag on linux. (ref) This flag doesn't seem to be there on darwin. Context I'm trying to use open ...
Alan's user avatar
  • 101
1 vote
1 answer
478 views

Retrieve the virtual page id from a virtual address

We know this following function from Linux kernel, which takes a pointer to the struct page and outputs the virtual address of the page frame: void * page_address(struct page *page) So I wonder if a ...
JGL's user avatar
  • 23
0 votes
0 answers
211 views

How to track open() syscalls in FUSE filesystem?

I want to track all open() syscalls of a process inside a FUSE filesystem. Two concerns: Is there any usecase, when open() syscall will not trigger a FUSE filesystem operation? For example syscall ...
Kuchara's user avatar
  • 133
2 votes
2 answers
529 views

Linux Page Cache Performance versus memcpy

I am benchmarking the write performance in the case that Linux writes the data to the page cache without throttling the process or syncing the data to the disk. The simple experiment I am doing looks ...
Gongotar's user avatar
-1 votes
1 answer
921 views

Empty hostname (sethostname)

For some unrelated reason I want to set the hostname of a Linux machine to an empty string using the sethostname system call. #include <unistd.h> int main() { sethostname("", 0); ...
Simon Fromme's user avatar
1 vote
1 answer
143 views

Why fcntl() range lock (some offset to length) is slower as compared to fcntl full file lock (0 offset to EOF)? [closed]

I am trying to write on 1 GB file from 8 different processes (every process will start writing from 0th offset till EOF) simultaneously; while following two different approaches. Before writing every ...
MankPan's user avatar
  • 67
5 votes
1 answer
575 views

Difference between posix_fadvise and readahead

As per manpage, readahead is Linux specific: CONFORMING TO The readahead() system call is Linux-specific, and its use should be avoided in portable applications. and posix_fadvise is portable: ...
arunanshub's user avatar
1 vote
0 answers
60 views

Output redirection ownership

When i execute cat file.txt > newfile.txt, which process or program is executing the syscall? I've tried using strace cat file.txt > newfile.txt to identify this, but havent been successful in ...
Hysii's user avatar
  • 111
0 votes
2 answers
458 views

Using statvfs to get total and free filesystem size

I want to use the return values from statvfs to get the total and free filesystem size. unsigned long f_bsize; /* Filesystem block size */ unsigned long f_frsize; /* Fragment size */ fsblkcnt_t ...
finefoot's user avatar
  • 2,980
0 votes
1 answer
779 views

getaddrinfo() return both ipv4 and ipv6 while local system has ipv4 only

I use getaddrinfo(3) to get list ip address from a domain which support both ipv4 and ipv6, but the local system support ipv4 only or both ipv4 & ipv6, As I expect, if system support both ipv4 &...
Nhâm Trần's user avatar
4 votes
0 answers
196 views

What could cause EROFS error for an openat call of a symlinked path, but only sometimes?

I'm trying to debug an issue which I see only intermittently, often only once or twice per server and then it goes away. I have an application which attempts to open a lock file using openat() with ...
Josh's user avatar
  • 8,321
0 votes
1 answer
33 views

How find out through terminal that if any system command uses specific system call internally?

I am new to linux.I want to that how to find out through terminal that if any system command uses specific system call internally? Suppose hard linking is to be performed . So "ln" command ...
sagar's user avatar
  • 101
0 votes
0 answers
353 views

httpd, avc: denied { unix_read unix_write }

I am new to selinux concept and here I am stuck on how to make httpd perform {unix_read unix_write} Below is the audit log message. type=IPC msg=audit(1624375715.312:4225): ouid=0 ogid=0 mode=0666 obj=...
Aryaman Gupta's user avatar
1 vote
0 answers
463 views

Strace displaying results in ASCII only at process ending and not runtime

I'm searching a way for strace to print the content of the write(...) syscall to ASCII and not useless bytes ! The Strace command I use : sudo strace -e write=1 -e trace=write -s9999 -p 551 2>&...
Doctor's user avatar
  • 133
1 vote
1 answer
184 views

how to declare a new variable in vvar.h |create a vdso in linux

I am trying to declare a new variable in vvar.h and define it near my new VDSO function. So that I could use this variable in my vdso function. I have a trouble about VVar. According to the ...
yaoxin jing's user avatar

1
2 3 4 5
7