A system call is used by programs to request services from the operating system's kernel.
Questions tagged [system-calls]
3690 questions
19
votes
3 answers
Is "asmlinkage" required for a c function to be called from assembly?
I am writing a C function that will be invoked from assembly code.
(Specifically, I want to do some checking job in the path of system call handling in linux kernel, so I will call the c function before a system call is dispatched in entry_32.S)
I…

Infinite
- 3,198
- 4
- 27
- 36
18
votes
5 answers
x86_64 Assembly Linux System Call Confusion
I am currently learning Assembly language on Linux. I have been using the book 'Programming From the Ground Up' and all the examples are 32-bit. My OS is 64-bit and I have been trying to do all the examples in 64-bit. I am having trouble…

Hudson Worden
- 2,263
- 8
- 30
- 45
18
votes
1 answer
How does a system call translate to CPU instructions?
Let's say there is a simple program like:
#include
void main()
{
int x;
printf("Cool");
fd = open("/tmp/cool.txt", O_READONLY)
}
The open is a system call here. I suppose when the shell runs it, it makes some hundred other…

Nishant
- 20,354
- 18
- 69
- 101
18
votes
1 answer
How to figure out if a file is a link?
I have the below code only a part of it is shown here and I am checking if a the type of file.
struct stat *buf /* just to show the type buf is*/
switch (buf.st_mode & S_IFMT) {
case S_IFBLK: printf(" block device\n"); break;
…

Eternal Learner
- 3,800
- 13
- 48
- 78
18
votes
4 answers
What is the difference between system call and library call?
Can someone explain the differences for these two in linux? Please go as deep as possible into each step the operating system takes.

drdot
- 3,215
- 9
- 46
- 81
18
votes
2 answers
Is there a better way than parsing /proc/self/maps to figure out memory protection?
On Linux (or Solaris) is there a better way than hand parsing /proc/self/maps repeatedly to figure out whether or not you can read, write or execute whatever is stored at one or more addresses in memory?
For instance, in Windows you have…

Edward Kmett
- 29,632
- 7
- 85
- 107
18
votes
1 answer
How do SYSCALL/SYSRET instructions perform across x86 CPUs?
SYSCALL and SYSRET (and their 32-bit-only Intel counterparts SYSENTER and SYSEXIT) are usually described as a “generally faster” way to enter and exit supervisor mode in x86 processors than call gates or software interrupts, but the exact figures…

Alex Shpilkin
- 776
- 7
- 17
18
votes
5 answers
How to pass arguments to processes created by fork()
I want to create copies of a process using fork() in C.
I cant figure out how to pass arguments to the copies of my process.
For example,I want to pass an integer to the process copies.
Or I what to do, if I have a loop in which I call fork() and…

Basti
- 373
- 2
- 6
- 12
18
votes
5 answers
Programmatically getting UID and GID from username in Unix?
I'm trying to use setuid() and setgid() to set the respective id's of a program to drop privileges down from root, but to use them I need to know the uid and gid of the user I want to change to.
Is there a system call to do this? I don't want to…

Evan
- 635
- 1
- 8
- 19
17
votes
3 answers
System calls overhead
I just started studying about system calls.
I would like to know what causes overhead when a system call is made.
For example,
if we consider getpid(), when a system call is made to getpid() my guess is that if the control is…

user3344978
- 644
- 1
- 8
- 22
17
votes
2 answers
poll system call timeout
Attaching strace shows a lot of these messages:
poll([{fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}, {fd=9, events=POLLIN}, {fd=10, events=POLLIN}], 6, 0) = 0 (Timeout)
poll([{fd=5, events=POLLIN},…

mahmood
- 23,197
- 49
- 147
- 242
16
votes
1 answer
compile errors using signal.h in Linux
I'm writing a shell program that must handle signals. My relevant signal handling related code is as follows:
#include
...
#include
...
void installSigactions( int, struct sigaction* );
void handler_function( int signal_id…

rurouniwallace
- 2,027
- 6
- 25
- 47
16
votes
1 answer
ptrace and threads
I'm working on an linux application incorporating ptrace to observe the threads of another process. When the application I observe forks a child process this already works quite well. By calling waitpid in my application I can obtain the following…

mupro
- 333
- 2
- 11
16
votes
3 answers
How to hide command prompt window when using Exec in Golang?
say i have the following code, using syscall to hide command line window
process := exec.Command(name, args...)
process.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
err := process.Start()
if err != nil {
log.Print(err)
}
but when i…

jm33_m0
- 595
- 2
- 9
- 17
16
votes
3 answers
Windows equivalent to Linux's readahead syscall?
Is there a Windows equivalent to Linux's readahead syscall?
EDIT:
I would like a full function signature if possible, showing the equivalent offset/count parameters (or lower/upper).
Eg:
The Linux function signature is:
ssize_t readahead(int fd,…

joemoe
- 5,734
- 10
- 43
- 60