Questions tagged [system-calls]

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

3690 questions
1
vote
3 answers

How can I make the program automatically exit after audio played over

I'm writing a small tool, it can play audio file in the command/terminal like sox. I'm using bass.dll and Golang syscall for Windows. Here is my code, files can downloaded from comments, only run on Windows X64. bass.go on github gist package…
raoyc
  • 191
  • 8
1
vote
1 answer

What are the arguments of syscall (2) and their purpose?

I came across this wikibook which shows that there can be 7 arguments passed to syscall, and I want to understand what is the purpose of each one of them. This is not specified in the man page. Also, I have found a table of the arguments you can…
Eliran Turgeman
  • 1,526
  • 2
  • 16
  • 34
1
vote
0 answers

Debian 10 System Call Table is empty

I was trying to follow a course guide about kernel and it was going good until the instructions said that i need to open syscall_64.tbl and write a line in there. in the video the file is full but when i open mine i see nothing. and since i am…
Melisa
  • 33
  • 3
1
vote
1 answer

How to write text containing newline given as command line arguments in C?

I want to create a text file with mulitple lines using system calls in C and populate it with the text provided as command line arguments. This is what I wrote: #include #include #include #include #include…
1
vote
1 answer

Using write() to output string on stack

On Ubuntu 20, in x86-assembly, I am attempting to output a string pushed onto the stack using the write syscall. The little endian hexadecimal bytes pushed onto the stack are "hello world" in ASCII. My goal is to output the string solely from the…
ndks_43
  • 13
  • 3
1
vote
0 answers

Print hexadecimal as ascii with NASM system call

So I want to print out the ascii value of what is stored in an address with a system call. Lets say i want to print the letter Z in hex this is 0x5a, so lets say in my preamble there I have a pointer ptr point to a element of an array, I transfer…
liamod
  • 316
  • 1
  • 9
1
vote
1 answer

Calling mremap in Go doesn't work, but gives no error

I'm trying to mremap a file from Go, but the size of the file doesn't seem to be changing, despite the returned errno of 0. This results in a segfault when I try to access the mapped memory. I've included the code below. The implementation is…
1
vote
1 answer

mmap implementation in glibc - dynamic library with symbol mmap

I wanted to see how the Linux kernel function mmap() is implemented, so I downloaded the GNU C Library (glibc) source from the GNU page. (I downloaded glibc-2.27 because ldd --version told me I was using GLIBC 2.27) Now to find the definition of…
WannabeArchitect
  • 1,058
  • 2
  • 11
  • 22
1
vote
1 answer

Tracing a program from its entry point with ptrace (linux, c)

I want to trace registers & instructions of a program using ptrace. For a better understanding of my code i have reduced it to a point where it just counts the number of instructions of "/bin/ls". Here is my Code (ignore unnecessary…
Sbardila
  • 113
  • 6
1
vote
1 answer

How to call a user-defined syscall as a function

Lets say I have a user-defined syscall: foo (with code number 500). To call it, I simply write in a C file: syscall(SYS_code, args); How can I call it using just foo(args)?
Neeecu
  • 23
  • 1
  • 4
1
vote
2 answers

Interrupt sleep by signal

I want to write an C++ programm which should wait for a linux signal (millisecond resolution), but I am not able to find a possibility to achieve this. The following test code should terminate after 500ms, but it doesn't. #include…
gerum
  • 974
  • 1
  • 8
  • 21
1
vote
0 answers

Ptrace get execve filename

I trying to make a program like strace, but I'm stuck with the syscall execve, the registers rdi, rsi and rdx all contain 0 (I also tried with an assembler file that makes the hard-coded syscall), here's part of the code: regs = Registers() #…
Rayzeq
  • 25
  • 2
  • 6
1
vote
1 answer

Why am I not able to view the clone() system call in strace output when typing 'strace ls' in terminal?

My understanding is that when we type ls in the terminal: It invokes fork() library function which invokes system call clone() to create a child process. Then system call execve() is invoked to replace address space of the new process created with…
codinglover
  • 179
  • 1
  • 2
  • 10
1
vote
1 answer

user input with char array and fgets, output with write system call?

This code, for some reason, is giving me a corrupt final character- both writing to file and printf do not have the last character entered #include #include #include "ssem.h" int main(){ int sem_WF, sem_WF_key = 123456,…
man_idk
  • 55
  • 5
1
vote
1 answer

mv command implementation in C not moving files to different directory

I wrote a function in C that implements the mv command using Linux system calls. However, my implementation only works when renaming files. When I try to use my "mv" implementation to move a file to a different directory, the move seems to be…