Questions tagged [system-calls]

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

3690 questions
14
votes
1 answer

Difference between __NR_gettid and SYS_gettid

I was just looking at the way to get unique thread ID's in Linux. The way I found was to do as syscall with either of the two parameters as arguments: __NR_gettid OR SYS_gettid. Can anybody explain how they both differ with respect to each other?
user3328377
  • 151
  • 1
  • 4
14
votes
6 answers

"short read" from filesystem, when can it happen?

It is obvious that in general the read(2) system call can return less bytes than what was asked to be read. However, quite a few programs assume that when working with a local files, read(2) never returns less than what was asked (unless the file is…
Nakedible
  • 4,067
  • 7
  • 34
  • 40
14
votes
5 answers

Suppress console when calling "system" in C++

I'm using the system command in C++ to call some external program, and whenever I use it, a console window opens and closes after the command finishes. How can I avoid the opening of a console window? I would be happy if the solution could be…
Dana
  • 2,619
  • 5
  • 31
  • 45
14
votes
1 answer

How to set ulimit -n from a golang program?

My purspose was to set ulimit -n from within a golang program so that I do not have to set it globally but restrict it within the program. Found systemcalls setrlimit and get rlimit for the same. (http://linux.die.net/man/2/setrlimit) But when I…
George Thomas
  • 1,246
  • 2
  • 11
  • 14
14
votes
5 answers

What is the interface for ARM system calls and where is it defined in the Linux kernel?

I have read about system calls in Linux, and everywhere description is given regarding x86 architecture (0x80 interrupt and SYSENTER). But I am not able to track down the files and process for a system call in ARM architecture. Can anyone please…
shingaridavesh
  • 921
  • 1
  • 9
  • 19
14
votes
3 answers

Seeing all the system calls that were made by a Java program

How can I see which system calls my Java program is making? Is there a tool that will do this on Linux?
Ragini
  • 1,509
  • 7
  • 28
  • 42
13
votes
4 answers

How does sched_setaffinity() work?

I am trying to understand how the linux syscall sched_setaffinity() works. This is a follow-on from my question here. I have this guide, which explains how to use the syscall and has a pretty neat (working!) example. So I downloaded the Linux…
poundifdef
  • 18,726
  • 23
  • 95
  • 134
13
votes
3 answers

Implementation of system calls / traps within Linux kernel source

I'm currently learning about operating systems the use of traps to facilitate system calls within the Linux kernel. I've located the table of the traps in traps.c and the implementation of many of the traps within entry.S. However, I'm instructed to…
eprogrammer
  • 131
  • 1
  • 4
13
votes
2 answers

How does the gettimeofday syscall wor‍k?

gettimeofday is a syscall of x86-86 according to this page(just search gettimeofday in the box): int gettimeofday(struct timeval *tv, struct timezone *tz); I thought the disassembly should be easy enough, just prepare the two pointers and call the…
asker
  • 2,159
  • 3
  • 22
  • 27
13
votes
5 answers

Separating a string in C++

I am trying to separate a string into multiple strings, to make a customized terminal. So far I have been separating control signals using strtok, however I do not understand how to separate specific instances of a character. For example: string…
divyanshch
  • 390
  • 5
  • 15
13
votes
1 answer

Cross platform way of testing whether a file is a directory

Currently I have some code like (condensed and removed a bunch of error checking): dp = readdir(dir); if (dp->d_type == DT_DIR) { } This works swimmingly on my Linux machine. However on another machine (looks like SunOS, sparc): SunOS HOST 5.10…
Alex Gaynor
  • 14,353
  • 9
  • 63
  • 113
13
votes
1 answer

Can we call system call in kernel space?

Sometimes, when we have to call system call in kernel system, we invoke it's helper or related kernel functions, instead do 'syscall'. I am still wondering can we call system call in kernel space? If not, what stops us doing that. My question is a…
liuyruc
  • 301
  • 1
  • 3
  • 10
13
votes
2 answers

Accessing a system call directly from user program

On Ubuntu - kernel 2.6.32.2 How to call already existing system call from user code directly without help of any library? I read in books and on internet to solve this then written following code but still getting error. Please help Want to find…
Omkant
  • 9,018
  • 8
  • 39
  • 59
13
votes
2 answers

write or printf, which is faster?

After doing the following test: for( i = 0; i < 3000000; i++ ) { printf( "Test string\n" ); } for( i = 0; i < 3000000; i++ ) { write( STDOUT_FILENO, "Test string\n", strlen( "Test string\n" ) ); } it turns out that the calls to printf take…
rurouniwallace
  • 2,027
  • 6
  • 25
  • 47
13
votes
3 answers

Filter out broken pipe errors

I'm getting an error returned from an io.Copy call, to which I've passed a socket (TCPConn) as the destination. It's expected that the remote host will simply drop the connection when they've had enough, and I'm not receiving anything from…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526