Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
13 views

I want ideas to trace which app is rebooting my android [migrated]

Some process is rebooting my phone every time it connects to Wi-Fi. I thought of connecting it to the PC and do an strace in init or zygote or the system server, but I don't know what to look for in ...
0
votes
0answers
78 views

execve(2) not launching system commands

I am trying to implement a container, and for that I create a process using the clone(2) system call with the appropriate flags: if ((child_pid = clone(child_main, process_struct.Stack + ...
1
vote
1answer
67 views

Invalid arguments when mounting with MS_SHARED

I am trying to mount the ext4 file system on /mnt into mount_dir which is a temporary directory I created using mkdtemp(2) with MS_SHARED then a remount with MS_PRIVATE, The idea is creating a mount ...
0
votes
1answer
25 views

pivot_root(2) causes system crash

I am trying to change the root of my process to new file system that I mounted at /tmp/mount_dir and i have created another directory inside it /tmp/mount_dir/inner_mount_dir, and according to the man ...
0
votes
0answers
40 views

How does bash implement the “|” operator? [duplicate]

I have a question regarding the pipe operator ("|"). How does bash connect the output of one command or process to the input of another? Is it using the pipe system call or some other way? A sample ...
11
votes
6answers
18k views

What is the difference between a Library call and a System call in Linux?

I would like to know what is the difference between a Library call and a System call in Linux. Any pointers for a good understanding of the concepts behind both will be greatly appreciated.
1
vote
0answers
22 views

Change format of syscall event trace output to ftrace

I enabled ftrace event tracing for sys_enter_openat syscall. The respective output format given at events/syscalls/sys_enter_openat/format is print fmt: "dfd: 0x%08lx, filename: 0x%08lx, flags: 0x%...
2
votes
1answer
71 views

How Linux finds out about illegal memory access error?

I have a question about how Linux traps memory access errors. As far as I know, a user space program doesn't need to ask operating system every time it wants to access memory, now when the process ...
-2
votes
1answer
766 views

Is using system() function inside C++ code a fast way as using source codes? [closed]

As I know I can use system() function to using Linux terminal's commands inside my C++ code. For example system("aplay sound.wav");. I don't know can I write all the Linux commands like this or not, ...
0
votes
0answers
39 views

What's the implementation of system call interruption? Why system call can be interrupted by signals? [duplicate]

As I have read from the book Computer Science: from A Programmer's Perspective, received signals are handled at the moment process shifts from kernel mode to user mode, usually returning from a system ...
0
votes
2answers
358 views

What is interrupted system call?

I am reading APUE and the Interrupted System Calls chapter confuses me. I would like to write down my understanding based on the book, please correct me. A characteristic of earlier UNIX systems ...
2
votes
1answer
27 views

Other permissions apart from filesystem access

Quoted from this answer about the difference between filesystem user id and effective user id of a process, it says that The FSUID is used for filesystem accesses, the EUID for other things. What ...
1
vote
3answers
378 views

Is system call the only way that a user program can intentionally affect the state of a Linux kernel?

I think there are several ways that a user program can intentionally affect the state of a Linux kernel. By invoking a system call; By invoking mmap() and writing the memory that has been mapped to ...
0
votes
1answer
26 views

How to lock some resource in a shared network namespace

I would like to implement the functionality similar to pid file but for network namespace. In common file namespace the process can lock pid file and ensure that no other process is running in the ...
1
vote
1answer
31 views

Can I stop a system call before it is executed using Stackable Filesystems? [closed]

Let's assume that I have an application X. I only track system calls that X issues. For example in systems like "CS-STILo". The system detects anomalous sequences of system calls to detect code reuse ...
1
vote
1answer
44 views

MacOS's counterpart to Linux's unshare(2)

Does MacOS have a counterpart to Linux's unshare(2)? I'd like for the following to fail on both systems. #define _GNU_SOURCE #include <stdlib.h> #include <sched.h> int main() { #if ...
1
vote
1answer
97 views

Shell crash and how to debug it

As part of my C application running on Linux, I call a script using the system( ) library function. This script does a umount of a connected USB flash drive. Very rarely (1 in 7-8k) iterations, I see ...
0
votes
1answer
62 views

How does Linux knows if a process is allowed to issue a system call?

Let's say that a process wants to issue a system call that can only be issued by a privileged process. How does Linux knows whether to allow the process to issue such system call or not, does Linux ...
7
votes
2answers
2k views

`EINTR`: is there a rationale behind it?

Small talk as background EINTR is the error which so-called interruptible system calls may return. If a signal occurs while a system call is running, that signal is not ignored and a signal handler ...
3
votes
1answer
447 views

Determine free space available on a USB flash drive in C (linux)

I would like to figure out the available free space on a USB flash drive in a C program in Linux. I have earlier used system("df -h /dev/sda1") to figure it out but using system command in a Linux C ...
1
vote
1answer
94 views

how was the pipe(2) system call working in “traditional” Unix

This is what perldoc -f syscall says: There's a problem with syscall(SYS_pipe()): it returns the file number of the read end of the pipe it creates, but there is no way ...
1
vote
1answer
123 views

How does `execve()` call a special start-up routine and the main() function?

When a C program is executed by the kernel—by execve(), where does execve() call a special start-up routine crt0 which is called before the main function is called? where does execve() call ...
372
votes
7answers
41k views

How can I find the implementations of Linux kernel system calls?

I am trying to understand how a function, say mkdir, works by looking at the kernel source. This is an attempt to understand the kernel internals and navigate between various functions. I know mkdir ...
5
votes
1answer
1k views

Remounting read-only without changing other options

Working on systemd-shutdown, it is using mount() to remount filesystems as read-only. /* MS_REMOUNT requires that the data parameter * should be the same from the original mount * except for the ...
8
votes
4answers
3k views

When to call fork() and exec() by themselves?

I'm learning about fork() and exec() commands. It seems like fork() and exec() are usually called together. (fork() creates a new child process, and exec() replaces the current process image with a ...
0
votes
1answer
1k views

Using system function call to execute a shell command [closed]

I am trying to make a few directories and files using the system call. ex) system("mkdir directory3"); I am having trouble getting started. This is what I have so far: #include <stdio.h> int ...
-8
votes
1answer
94 views

How can we tell if a signal can interrupt the execution of a system call?

From The Linux Programming Interface a signal is delivered at one of the following times: when the process is rescheduled after it earlier timed out (i.e., at the start of a time slice); or ...
12
votes
1answer
10k views

How long is a TCP local socket address that has been bound unavailable after closing?

On Linux (my live servers are on RHEL 5.5 - the LXR links below are to the kernel version in that), man 7 ip says: A TCP local socket address that has been bound is unavailable for some time after ...
0
votes
2answers
466 views

pass stdout fd to 'read' system call, but it still works fine [duplicate]

I pass 1(stdout)/2(stderr) to read system call but it still works fine. Then I pass 0(stdin) to write system call and find out it works too! int main(int argc, char** argv){ char buf[1024] = "...
2
votes
1answer
907 views

what is a Kernel? [closed]

I'm learning Unix from the Unix Architecture book by Maurice J Bach. My confusion is with the concept of kernel. What is a kernel? I understand it's the operating system and it is a process. But ...
1
vote
1answer
406 views

How does FIO benchmark set IOdepth?

NOTE: My question stems from this other U&L Q - What exactly is iodepth in fio? I want to know how internally FIO sets I/O depth. I.e., one of the parameters we submit to FIO when we run it is "...
1
vote
1answer
2k views

file operations aio_read changed in kernel 4.1

I have a driver I maintain, I need to compile it with Linux headers 4.1.21 but I get compile errors for aio_read, aio_write, they are missing from struct file_operations, I assume they were replaced. ...
0
votes
1answer
44 views

nautilus not call write system call when paste file

I'm trying to hook some system calls using linux kernel module on Ubuntu 14.04 Desktop version. However, when I hooked write(unsigned int fd, const char __user *buf, size_t count) and turned fd into ...
2
votes
1answer
55 views

What system call does Evince use to open pdf?

I have tried to hook system calls using linux kernel module. However, when I open a pdf file using Evince, I find no open,read and write is used on this specific file, only lstat is used. Here is ...
1
vote
1answer
128 views

create a vdso in linux [closed]

I'm currently trying to implement my own VDSO. I have seen this tutorial which explains how to do this. However, this tutorial is made for Linux 2.6.x and I would like to use it on Linux 4.8.x. But ...
0
votes
1answer
288 views

Why could a call to `getaddrinfo()` fail with `EAI_SYSTEM` and errno set to `EBUSY` (“Device or resource busy”)?

I'm seeing this error when running apt update in containers, if that is useful information. apt spits out: System error resolving 'archive.ubuntu.com:80' - getaddrinfo (16: Device or resource busy) ...
2
votes
1answer
205 views

Does nohup try to arrange for the program not to have a controlling terminal?

Gilles said nohup and disown both can be said to suppress SIGHUP, but in different ways. nohup makes the program ignore the signal initially (the program may change this). nohup also tries to ...
3
votes
1answer
129 views

Atomically write a file without changing inodes (preserve hard link)

The normal way to safely, atomically write a file X on Unix is: Write the new file contents to a temporary file Y. rename(2) Y to X In two steps it appears that we have done nothing but change X "...
2
votes
0answers
102 views

How do I make my own Linux system call output to the process's terminal instead of to the kernel log?

I wrote a system call that outputs system information to the kernel log. Here is an example program that invokes my system call. #include <stdio.h> #include <linux/unistd.h> int main() { ...
3
votes
3answers
675 views

In what shared library is read()?

I want to know where the system call read() is. Which shared library is linked when I call read()?
-2
votes
1answer
378 views

Is every system call an atomic operation? [closed]

APUE says We saw another example of an atomic operation when we described the O_CREAT and O_EXCL options for the open function. When both of these options are specified, the open will fail if ...
3
votes
0answers
54 views

What subset of Linux does recent WSL support? [closed]

I know well Linux but nothing about WSL or Windows. I'm using Linux since 1993, but I never used Windows (and probably won't use it before my retirement, e.g. before 2024, so I am likely to never use ...
0
votes
2answers
189 views

Use waitpid for child having groupid 1

I searched a lot but didn't find a solution. So it can be silly question. The format of waitpid is pid_t waitpid (pid_t pid, int *status, int options) The pid parameter specifies exactly which ...
1
vote
1answer
89 views

What does SYSENTER do in 64-bit Long mode on Linux?

There is an x86 instruction sysenter. This seems to be the Intel fast-system-call method. SYSENTER seems to be valid in LONG mode (64-bit) on Intel processors. This seems to have fallen out of favor ...
3
votes
2answers
477 views

Why did the system call registers and order change from Intel 32bit to 64bit?

I was working on memorizing the order of the Linux system calls so I could more easily identify this. And, then I found this paper here, and it says, To make a system call in 32-bit Linux, place ...
21
votes
4answers
6k views

How to understand pipes

When I just used pipe in bash, I didn't think more about this. But when I read some C code example using system call pipe() together with fork(), I wonder how to understand pipes, including both ...
10
votes
3answers
2k views

What is the time unit that strace uses when displaying time spent in syscalls?

When using the command strace with the flag -T, I would like to know what is the time unit used to display time spent in syscalls? I assume it should be in seconds, but I am not quite sure and it ...
3
votes
1answer
263 views

Why I can not drop sudo root privileges?

I am debugging a program and not quite sure why I can not drop privileges. I have root permissions via sudo and I can call setgid/setuid, but the operation [is] is not supported. Basic code to ...
1
vote
1answer
269 views

How can I make a specific process exec a given executable with ptrace()?

I am trying to force the init process of an embedded Linux system to exec() my own init program (systemd) so that I can test an external filesystem before writing it to the system's flash (and risk ...
2
votes
1answer
913 views

Why system call hooking produces different result every time in Linux/Android 2.6.29?

I have implemented system call hooking for Android 2.6.29 kernel through a LKM module. I am tracing down one Android app for system calls. But interestingly, it returns different results every time I ...