Questions tagged [system-calls]

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

3690 questions
22
votes
7 answers

How can I get a list of Linux system calls and number of args they take automatically?

I writing a Linux system call map for the radare2 debugger. This means providing a huge static array mapping system call number to a syscall name name and the number of arguments it takes. This was easy for OpenBSD as the syscall numbers are defined…
Edd Barrett
  • 3,425
  • 2
  • 29
  • 48
22
votes
3 answers

gdb break when program opens specific file

Back story: While running a program under strace I notice that '/dev/urandom' is being open'ed. I would like to know where this call is coming from (it is not part of the program itself, it is part of the system). So, using gdb, I am trying to…
zdav
  • 2,752
  • 17
  • 15
22
votes
2 answers

Under what circumstances does the read() syscall return 0?

I'm looking at the read syscall in Unix, which (at least in Linux) has this signature: [1] ssize_t read(int fd, void* buf, size_t count); Let's assume that the call succeeds (i.e. no negative return values) and that count > 0 (i.e. the buffer…
Stefan Majewsky
  • 5,427
  • 2
  • 28
  • 51
22
votes
1 answer

Huge memory leak in repeated os.path.isdir calls?

I've been scripting something that has to do with scanning directories and noticed a severe memory leak when calling os.path.isdir, so I've tried the following snippet: def func(): if not os.path.isdir('D:\Downloads'): return False while…
AAlon
  • 434
  • 3
  • 8
21
votes
3 answers

What does "int 21h" mean in Assembly?

I'm new to learning assembly language, and I'm wondering what the command int 21h means. For example: mov ah,01h int 21h Which should read a key from the user.
BOSS
  • 1,828
  • 11
  • 34
  • 60
21
votes
1 answer

What is the difference between `read` and `sysread`?

read and sysread have very similar documentation. What are the differences between the two?
ikegami
  • 367,544
  • 15
  • 269
  • 518
21
votes
1 answer

List of and documentation for system calls for XNU kernel in OSX

I'm trying to figure out how to get a list of and documentation for the system calls available in the XNU kernel in OSX. I've googled around quite a bit, but haven't been able to find anything of use. As I understand the calling conventions match…
Daniel Brotherston
  • 1,954
  • 4
  • 18
  • 28
20
votes
4 answers

How are sbrk/brk implemented in Linux?

I was thinking about how the Linux kernel implements system calls and I was wondering if someone could give me a high level view of how sbrk/brk work? I've reviewed the kernel code, but there is just so much of it and I don't understand it. I was…
samoz
  • 56,849
  • 55
  • 141
  • 195
20
votes
1 answer

New syscall not found (linux kernel 3.0.0) where should I start looking?

I created two new syscalls, but when I try to test them I get the following error: matt@ubuntu:~/test$ gcc test.c test.c: In function ‘newcall’: test.c:6:17: error: ‘sys_get_slob_amnt_free’ undeclared (first use in this function) test.c:6:17: note:…
MatrixManAtYrService
  • 8,023
  • 1
  • 50
  • 61
20
votes
1 answer

If close(2) fails with EIO, will the file descriptor still be deleted?

If a close(2) system call fails with EIO, will the file descriptor still be deleted? If yes, is it not possible to handle a spurious IO error by retrying later? If no, how should one prevent a file descriptor leak?
fornwall
  • 2,877
  • 3
  • 25
  • 38
20
votes
4 answers

Why is data written to a file opened with O_APPEND flag, always written at the end, even with `lseek`?

I have been given a programming assignment: Write a program that opens an existing file for writing with the O_APPEND flag, and then seeks to the beginning of the file before writing some data. Where does the data appear in the file? Why? What I…
KarimS
  • 3,812
  • 9
  • 41
  • 64
20
votes
3 answers

Interpret dtruss output like “psynch_cvwait(...) = -1 Err#316”

dtruss appears to be a useful tool to analyze the (mis-)behaviour of applications on OS X. The closes thing I found to my beloved strace on linux. But interpreting its output requires an understanding of the syscalls it refers to, and sometimes the…
MvG
  • 57,380
  • 22
  • 148
  • 276
20
votes
3 answers

How to access the system call from user-space?

I read some paragraphs in LKD1 and I just cannot understand the contents below: Accessing the System Call from User-Space Generally, the C library provides support for system calls. User applications can pull in function prototypes from the…
injoy
  • 3,993
  • 10
  • 40
  • 69
19
votes
5 answers

How can I make the system call write() print to the screen?

For my OS class I'm supposed to implement Linux's cat using only system calls (no printf) Reading this reference I found it being used to print to a file. I guess I should manipulate ofstream. In the example appears: ofstream outfile…
andandandand
  • 21,946
  • 60
  • 170
  • 271
19
votes
2 answers

System calls on Windows

I just want to ask, I know that standart system calls in Linux are done by int instruction pointing into Interrupt Vector Table. I assume this is similiar on Windows. But, how do you call some higher-level specific system routines? Such as how do…
B.Gen.Jack.O.Neill
  • 8,169
  • 12
  • 51
  • 79