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.

373
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 ...
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 ...
25
votes
2answers
5k views

Where is the fork() on the fork bomb :(){ :|: & };:?

Warning: Running this command in most shells will result in a broken system that will need a forced shutdown to fix I understand the recursive function :(){ :|: & };: and what it does. But I don'...
3
votes
1answer
1k views

How does fork system call really works

I've a very specific question about fork system call. I've this piece of code: int main (void) { for (int i = 0; i < 10; i++) { pid_t pid = fork (); if ( !pid ) { ...
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 ...
9
votes
3answers
820 views

Making a process read a different file for the same filename

I have an application that reads a file. Let's call it processname and the file ~/.configuration. When processname runs it always reads ~/.configuration and can't be configured differently. There are ...
12
votes
2answers
11k views

What's the difference between fork() and vfork()?

I would like to understand in detail the difference between fork() and vfork(). I was not able to digest the man page completely. I would also like to clarify one of my colleagues comment "In ...
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 ...
9
votes
3answers
2k views

System calls supported in running Kernel

Is there a way to get the number of or list of system calls supported by currently running Linux Kernel? So I want to find a way to 'read' the syscall table of a running kernel.
98
votes
5answers
368k views

How to find application's path from command line?

For example, I have git installed on my system. But I don't remember where I installed it, so which command is fit to find this out?
8
votes
2answers
6k views

Which file in kernel specifies fork(), vfork()… to use sys_clone() system call

When ltrace is used for tracing the system calls, I could see that fork() uses sys_clone() rather than sys_fork(). But I couldnt find the linux source where it is defined. My program is #include<...
43
votes
4answers
5k views

Why are UNIX/POSIX system call namings so illegible?

What is the reason to use such untelling system call names like time and creat instead of getCurrentTimeSecs and createFile or, maybe more suitable on Unix get_current_time_secs and create_file. Which ...
10
votes
4answers
20k views

Difference between system calls and library functions

I have been through the answer of this question but do not quite understand the difference between system calls and library functions. Conceptually, what is the difference between the two?
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.
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 ...
5
votes
3answers
947 views

API with no system calls

The book 'Understanding Linux Kernel' says that 'for something abstract such as math functions, there may be no reason to make system calls'. Can any one please explain how is a system call not ...
2
votes
2answers
4k views

Execute system calls directly

Provided a user is authorized to access something, how can he execute a system call directly, like geteuid() - get effective user ID (it's just an example) from bash, how could I do it?
1
vote
1answer
248 views

In what library on Linux are the system calls and how is this library linked to the executable object file that contains the system calls?

I know that the system calls are not in the C standard Library. Is there any library (some sort of a system library) where the system calls are? If there is such a library how is this library linked ...
9
votes
1answer
2k views

Why are rmdir and unlink two separate system calls?

Here's something that kept me wondering for a while: [15:40:50][/tmp]$ mkdir a [15:40:52][/tmp]$ strace rmdir a execve("/usr/bin/rmdir", ["rmdir", "a"], [/* 78 vars */]) = 0 brk(0) ...
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 ...
2
votes
1answer
1k views

Strace Hello World program

So I am trying to understand systemcalls with the following "Hello World!" program: #include <stdio.h> int main(){ printf("Hello World!\n"); return 0; } and then I run strace on the ...
1
vote
2answers
853 views

How to notice log file changes with Linux standard tools? [duplicate]

I need something that does not need to be installed. It's on an embedded system with very little space on the HD. I can't instal anything. I need to do it with something that is already included. I ...
7
votes
1answer
959 views

What am I supposed to use `O_PATH` for, and how?

I use a Linux 4.x-based distribution, and I've recently noticed the kernel's open() system call supports an O_PATH open flag. While the man page for it does have a list of system calls it could ...
6
votes
2answers
12k views

How to find the header file where a c function is defined?

Is there an easy way to find out which header file a C function declaration is in? cding into /usr/include and running (grep -E 'system.*\(' *.h -R) works with some trial and error, but isn't there an ...
5
votes
3answers
980 views

How can you change the process name of Wing IDE from python to something more descriptive

In my process list under Ubuntu (using top/System Monitor) one of the largest memory hogs (200+Mb) was python. I searched a bit for one of my programs to be the cause until I realised this was my ...
4
votes
2answers
4k views

Why can the waitpid system call only be used with child processes?

The man page wait(2) states that the waitpid system call returns the ECHILD error if the specified process is not a child of the calling process. Why is this? Would waiting on a non-child process ...
4
votes
4answers
6k views

Understand error codes in Linux

I am working on Linux (Kernel Version 2.6.32.28) laptop. After I inserted/did file io/removed a SD combo card, I got following errors: mmcblk0: error -123 sending status command mmcblk0: error -...
4
votes
1answer
745 views

syscall number → name mapping at runtime

Is there a way to resolve the number of an observed syscall: SYS_345(0xe, 0xbff94188, 0x2, 0x4000, 0xb6526000) = 2 to its symbolic name in the running kernel without looking it up, in the sources? ...
3
votes
3answers
3k views

Command to trace rsh server to check behaviour of particular system call

I am working with rsh. I want to check the whole process from beginning to end. For that I used strace. Os name is CentOS. I am working on single machine, server and client are on same machine. My ...
3
votes
2answers
2k views

Are system calls the only way to interact with the Linux kernel from user land?

Are there any other interfaces, e.g. the /proc filesystem?
3
votes
2answers
478 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 ...
2
votes
2answers
2k views

Linux System calls in C on OSX

So I did a quick test and #include <sys/types.h> #include <unistd.h> #include <stdio.h> int main (int argc, char *argv[]) { printf("Hello World\n"); printf("%d\n",...
1
vote
1answer
407 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

Occasional error from bash on AIX: Interrupted system call

I am experiencing problems with process substitution in bash on AIX It happens very rarely, apparently only when the server is loaded. An example error message is: line 9: /tmp//sh-np-7841523: ...
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 ...
-2
votes
1answer
382 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 ...