Questions tagged [system-calls]

A system call is used by programs to request services from the operating system's kernel.

3690 questions
28
votes
2 answers

How to invoke a system call via syscall or sysenter in inline assembly?

How can we implement the system call using sysenter/syscall directly in x86 Linux? Can anybody provide help? It would be even better if you can also show the code for amd64 platform. I know in x86, we can use __asm__( " movl $1, %eax …
Infinite
  • 3,198
  • 4
  • 27
  • 36
28
votes
4 answers

History of syscalls added to Linux?

Is there anywhere I can get a complete list of the minimum version of Linux needed for each syscall? I'm looking for a general answer to questions of the form "If I use syscall X, what is the minimum version of Linux on which my code can run?"
R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711
27
votes
2 answers

How does this C program without libc work?

I came across a minimal HTTP server that is written without libc: https://github.com/Francesco149/nolibc-httpd I can see that basic string handling functions are defined, leading to the write syscall: #define fprint(fd, s) write(fd, s,…
qwr
  • 9,525
  • 5
  • 58
  • 102
26
votes
3 answers

C++ gettid() was not declared in this scope

A simple program is: I would like to get the thread ID of both of the threads using this gettid function. I do not want to do the sysCall directly. I want to use this function. #include #include #include…
Hiesenberg
  • 415
  • 1
  • 8
  • 12
25
votes
2 answers

Linux system call for creating process and thread

I read in a paper that the underlying system call to create processes and threads is actually the same, and thus the cost of creating processes over threads is not that great. First, I wanna know what is the system call that…
atoMerz
  • 7,534
  • 16
  • 61
  • 101
25
votes
10 answers

how could I intercept linux sys calls?

Besides the LD_PRELOAD trick , and Linux Kernel Modules that replace a certain syscall with one provided by you , is there any possibility to intercept a syscall ( open for example ) , so that it first goes through your function , before it reaches…
Vhaerun
  • 12,806
  • 16
  • 39
  • 38
24
votes
3 answers

How does strace work?

It can trace all system calls used. But what differs a sys_call from a normal call??
gdb
  • 7,189
  • 12
  • 38
  • 36
24
votes
3 answers

How to check the value of errno?

I am using a system call and in case it fails, I need to do different things for different errnos. I need to write code that looks something like this: int res; res = systemCall(); if (res == -1) { if (errno == ENOMSG) { …
Hana
  • 535
  • 2
  • 7
  • 17
24
votes
3 answers

How to make a call to an executable from Python script?

I need to execute this script from my Python script. Is it possible? The script generate some outputs with some files being written. How do I access these files? I have tried with subprocess call function but without…
fx.
  • 1,217
  • 3
  • 10
  • 17
24
votes
1 answer

Windows system calls

I have a (very) basic understanding of assembly using system calls on Linux (I use the GNU assembler as). On Windows 7, I am using the MinGW (32-bit) port of the GCC compiler suite to produce assembler programs. On Linux I regularily use the C…
DiscobarMolokai
  • 544
  • 2
  • 6
  • 20
24
votes
3 answers

Which linux system call is used by ls command in linux to display the folder/file name?

I wanted to know which system call is used in linux by the ls command to display the folder's (or file's name)? Especially the files/folders starting with "." (dot) I executed the strace ls -a command to look at the system calls.There is a lot of…
footy
  • 5,803
  • 13
  • 48
  • 96
23
votes
3 answers

Is malloc/free a syscall or a library routine provided by libc?

If malloc/free is implemented as a library routine in libc, then is it implemented on top of the sbrk syscall or the mmap syscall, or something else? And to be general, does the function declared in sys/syscall.h contains ALL the system calls in the…
Pwn
  • 3,387
  • 11
  • 38
  • 42
23
votes
4 answers

Can eBPF modify the return value or parameters of a syscall?

To simulate some behavior I would like to attach a probe to a syscall and modify the return value when certain parameters are passed. Alternatively, it would also be enough to modify the parameters of the function before they are processes. Is this…
Georg Schölly
  • 124,188
  • 49
  • 220
  • 267
23
votes
1 answer

How does a system call work

How does system calls work ? What are the operations happen during system call? There are various system call like open , read, write, socket etc. I would like to know how do they work in general ?
Rocoder
  • 1,083
  • 2
  • 15
  • 26
23
votes
6 answers

Difference between write() and printf()

Recently I am studying operating system..I just wanna know: What’s the difference between a system call (like write()) and a standard library function (like printf())?
CSnerd
  • 2,129
  • 8
  • 22
  • 45