Questions concerning the details of how a program uses system calls to interact with the kernel API, what calls are available, how they work etc.

learn more… | top users | synonyms

21
votes
2answers
3k views

Where is the fork() on the fork bomb :(){ :|: & };:?

Warning: Running this command in most shells will result in a broken system that will need a forced shutdown to fix I understand the recursive function :(){ :|: & };: and what it does. But I ...
17
votes
5answers
52k views

How to find application's path from command line?

For example, I have git installed on my system. But I don't remember where I installed it, so which command is fit to find this out?
15
votes
4answers
2k views

How to understand pipes

When I just used pipe in bash, I didn't think more about this. But when I read some C code example using system call pipe() together with fork(), I wonder how to understand pipes, including both ...
12
votes
2answers
1k views

Equivalent of “truss -T” and “truss -U” on Linux?

Is there an equivalent of what the -T and -U option of the truss Solaris utility does on Linux. Those are to specify a system call (-T) or library function (-U) which when called by the traced ...
9
votes
5answers
1k views

What is meant by “a system call” if not the implementation in the programing language?

I would like to understand the term "system call". I am familiar that system calls are used to get kernel services from a userspace application. The part i need clarification with is the difference ...
9
votes
1answer
3k views

What's the difference between fork() and vfork()?

I would like to understand in detail the difference between fork() and vfork(). I was not able to digest the man page completely. I would also like to clarify one of my colleagues comment "In ...
9
votes
2answers
258 views

How a piped shell programs balance their output/input rates? [duplicate]

Possible Duplicate: Bash while loop and reading from pipe I come from web programming background, and find myself interested in one peculiarity of using a local shell. I understand that ...
9
votes
2answers
3k views

Interruption of system calls when a signal is caught

From reading the man pages on the read() and write() calls it appears that these calls get interrupted by signals regardless of whether they have to block or not. In particular, assume a process ...
8
votes
3answers
3k views

What is the relationship between system calls, message passing, and interrupts?

I am reading the Wikipedia article for process management. My focus is on Linux. I cannot figure out the relation and differences between system call, message passing and interrupt, in their concepts ...
8
votes
2answers
2k views

What's the purpose of the first argument to select system call?

From man select int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); nfds is the highest-numbered file descriptor in any of the three ...
8
votes
4answers
2k views

Why should a child of a vfork or fork call _exit() instead of exit()?

From the man page of vfork(): vfork() differs from fork() in that the parent is suspended until the child makes a call to execve(2) or _exit(2). The child shares all memory with its ...
8
votes
3answers
5k views

flock(2) versus fcntl(2) over a NFS

The Perl 5.x documentation states that its implementation of flock(..) will use one of the following native calls, starting at 1 and working toward 3 if unavailable: flock(2) fcntl(2) lockf(3) ...
7
votes
2answers
906 views

Which is more efficient, ls or ls -l?

As I understand, the ls command calls getdents, which returns up to x number of directory entries. Are there any other system calls involved? If I run ls -l, are there any more system calls? I am ...
7
votes
2answers
3k views

Difference between slow system calls and fast system calls

What's the difference between slow system calls and fast system calls? I have learned that slow system call can block if the process catches some signals, because the caught signals may wake up the ...
7
votes
1answer
2k views

getrusage system call: what is “maximum resident set size”

man getrusage 2 says ru_maxrss (since Linux 2.6.32) This is the maximum resident set size used (in kilobytes). For RUSAGE_CHILDREN, this is the resident set size of the largest ...
7
votes
1answer
124 views

Why are rmdir and unlink two separate system calls?

Here's something that kept me wondering for a while: [15:40:50][/tmp]$ mkdir a [15:40:52][/tmp]$ strace rmdir a execve("/usr/bin/rmdir", ["rmdir", "a"], [/* 78 vars */]) = 0 brk(0) ...
6
votes
2answers
187 views

System programming: How to gather info?

According to this question, a good way to learn system programming would be to implement the existing tools. I decided to try to rewrite ls and ps. My question is how would one proceed to get ...
6
votes
1answer
3k views

How long is a TCP local socket address that has been bound unavailable after closing?

On Linux (my live servers are on RHEL 5.5 - the LXR links below are to the kernel version in that), man 7 ip says: A TCP local socket address that has been bound is unavailable for some time after ...
5
votes
3answers
4k views

Difference between system calls and library functions

I have been through the answer of this question but do not quite understand the difference between system calls and library functions. Conceptually, what is the difference between the two?
5
votes
4answers
2k views

What is the difference between a Library call and a System call in Linux?

I would like to know what is the difference between a Library call and a System call in Linux. Any pointers for a good understanding of the concepts behind both will be greatly appreciated.
5
votes
3answers
303 views

How can you change the process name of Wing IDE from python to something more descriptive

In my process list under Ubuntu (using top/System Monitor) one of the largest memory hogs (200+Mb) was python. I searched a bit for one of my programs to be the cause until I realised this was my ...
5
votes
2answers
90 views

Making a process read a different file for the same filename

I have an application that reads a file. Let's call it processname and the file ~/.configuration. When processname runs it always reads ~/.configuration and can't be configured differently. There are ...
5
votes
1answer
350 views

DTrace to trap any chmod applied to certain files

Underneath the Mac OS X directory /audit I have certain files which users can access and chmod to their liking. I need to audit any chmod done on any files by recording the time, user and file being ...
5
votes
1answer
2k views

Hung system call

So I'm working with a custom kernel module that I'm writing a python front end for. The kernel module works, and it adds a framebuffer device file to /dev/fb1. I can read and write to it fine. I've ...
4
votes
4answers
2k views

Understand error codes in Linux

I am working on Linux (Kernel Version 2.6.32.28) laptop. After I inserted/did file io/removed a SD combo card, I got following errors: mmcblk0: error -123 sending status command mmcblk0: error ...
4
votes
2answers
3k views

How to find the header file where a c function is defined?

Is there an easy way to find out which header file a C function declaration is in? cding into /usr/include and running (grep -E 'system.*\(' *.h -R) works with some trial and error, but isn't there an ...
4
votes
1answer
671 views

Can you perform system calls from OSX Terminal?

So I get system calls in the context of a C program, but my textbook doesn't really address making system calls in Terminal (on Mac OSX). Can you do these on the command line like with "commands", or ...
4
votes
1answer
471 views

System call invokation methods in new kernel

I read that in the newer kernels system calls are invoked using the INT X80 instruction and also using the sysenter instruction. And also the sysenter instruction gives faster invocation as compared ...
3
votes
3answers
137 views

API with no system calls

The book 'Understanding Linux Kernel' says that 'for something abstract such as math functions, there may be no reason to make system calls'. Can any one please explain how is a system call not ...
3
votes
2answers
1k views

Which file in kernel specifies fork(), vfork()… to use sys_clone() system call

When ltrace is used for tracing the system calls, I could see that fork() uses sys_clone() rather than sys_fork(). But I couldnt find the linux source where it is defined. My program is ...
3
votes
2answers
2k views

Adding a new System call to Linux 3.2.x with a loadable kernel module [closed]

I want to add a particular new system call in the linux kernel 3.2.x but as a loadable kernel module (as I don't want to recompile the kernel again and again) I read through many posts on internet ...
3
votes
2answers
744 views

Wrapper program that sets signal handler

I would like to have a wrapper program that runs a given command and sets a signal handler so that it gets run when the command receives a specified signal. The question is this: Is there an ...
3
votes
1answer
52 views

Result from kernel returned to what process?

When a process requires actions that require kernel mode, it uses a system call. So, how are the results returned to the process?
3
votes
3answers
948 views

Command to trace rsh server to check behaviour of particular system call

I am working with rsh. I want to check the whole process from beginning to end. For that I used strace. Os name is CentOS. I am working on single machine, server and client are on same machine. My ...
3
votes
1answer
144 views

Efficient mechanism to determine if open file has been externally modified?

For example, the IDE I'm using at the moment (Aptana Studio) notifies me as soon as a file's contents it has open have been changed by some external program. I can imagine having a periodic loop run ...
3
votes
1answer
145 views

how to disallow user to change process group

Is it possible to restrict a process from changing it's process group? For example, user nobody seems to be able to call setpgid(0, 0) which sets process group of current process to pid of that ...
3
votes
1answer
59 views

Get device with major number 0 (btrfs subvolume)

When I stat a file on a btrfs subvolume I get a major device number of 0. Is there a reliable way to find the mount point of this device, without knowing in advance it is a btrfs subvolume? e.g. I'd ...
3
votes
1answer
889 views

Program stall under user but runs under root

I am running R job under a normal user john and root. Interestingly, the program stalls under john user but runs quickly under root. Using strace, I found that when john runs the R, the process stalls ...
2
votes
2answers
202 views

Are system calls the only way to interact with the Linux kernel from user land?

Are there any other interfaces, e.g. the /proc filesystem?
2
votes
3answers
154 views

In what shared library is read()?

I'm a Linux rookie and want to know where the system call read() is. Which shared library is linked when I call read()?
2
votes
2answers
77 views

Low level system call [closed]

C provides library functions such as write(),read().. for system calls.How to make a system call without using any library in linux in C ?
2
votes
3answers
340 views

Are all system call error numbers unique?

I'm writing a program for Systems Programming in Unix, and one of the requirements is to process all possible error returns from system calls. So, rather than having a function tailored to each ...
2
votes
1answer
489 views

How to decode cmd = 3222823425 in ioctl in Linux 2.6.29

I am just confused like how can I break cmd=3222823425 value into different parts to figure out what this command means actually in the Linux kernel. I know, some functions are making ioctl command ...
2
votes
2answers
1k views

exec() and system() system calls

I do understand that while exec() does not return after it executes in Unix ,system() may or may not return depending on the situation.But can anyone explain why exec() system call does not return and ...
2
votes
1answer
83 views

What is the use of “magic arguments” in Linux reboot system call?

As I was reading Linux source code, and more specifically the system calls code, I came across sys_reboot implementation: http://lxr.free-electrons.com/source/kernel/reboot.c#L199. 199 ...
2
votes
1answer
1k views

Linux source, where are sys_umount and sys_mount system calls? [duplicate]

Possible Duplicate: Understanding the linux kernel source I am sure that I must be missing something, here. I cannot for the life of me find the source code for these system calls. I can ...
2
votes
1answer
49 views

Is there a system call to bind a file descriptor directly into another?

A read() & write() loop would probably be as good as what I'm looking for, but nevertheless is anything like that around or is it impossible because of an obstacle I didn't envisage ? I'm curious
2
votes
2answers
3k views

Calculating total CPU system usage in C [closed]

I found this answer on StackOverflow for calculating total CPU usage: http://stackoverflow.com/questions/1420426/calculating-cpu-usage-of-a-process-in-linux/4497769#4497769 But how do I calculate ...
1
vote
1answer
59 views

Strace Hello World program

So I am trying to understand systemcalls with the following "Hello World!" program: #include <stdio.h> int main(){ printf("Hello World!\n"); return 0; } and then I run strace on the ...
1
vote
1answer
60 views

System calls in linux

Generally, systems provide a library or API that sits between normal programs and the operating system. On Unix-like systems, that API is usually part of an implementation of the C library (libc), ...