Jump to content
Nytro

LINUX System Call Quick Reference

Recommended Posts

Posted

LINUX System Call Quick Reference

Introduction

System call is the services provided by Linux kernel. In C programming, it often uses functions defined in libc

which provides a wrapper for many system calls. Manual page section 2 provides more information about

system calls. To get an overview, use “man 2 intro” in a command shell.

It is also possible to invoke syscall() function directly. Each system call has a function number defined in

<syscall.h> or <unistd.h>. Internally, system call is invokded by software interrupt 0x80 to transfer control to

the kernel. System call table is defined in Linux kernel source file “arch/i386/kernel/entry.S ”.

System Call Example

#include <syscall.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
int main(void) {
long ID1, ID2;
/*-----------------------------*/
/* direct system call */
/* SYS_getpid (func no. is 20) */
/*-----------------------------*/
ID1 = syscall(SYS_getpid);
printf ("syscall(SYS_getpid)=%ld\n", ID1);
/*-----------------------------*/
/* "libc" wrapped system call */
/* SYS_getpid (Func No. is 20) */
/*-----------------------------*/
ID2 = getpid();
printf ("getpid()=%ld\n", ID2);
return(0);
}

http://www.digilife.be/quickreferences/qrc/linux%20system%20call%20quick%20reference.pdf

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...