System Call
System programming starts and ends with the system call. Syscalls are function invocation made from user space (Eg. your text editor, favorite game etc) into the kernel space (The core internal of the system) in order to request some service or resource from the operating system.
Linux implements far fewer system call than any other operating system. X86_64 Linux uses around 350 syscalls, while Microsoft Windows uses thousands of syscalls.
Kernel provides its services to the user space programs with a set of tightly defined entry points know as system calls. Program don’t make system call directly, they do so by thin wrapper routines in the standard library called Glibc.
#include <fcntl.h> #include <stdio.h> #include <errno.h> #include <stdlib.h> int main() { int fd=open("/tmp/foo.txt",O_CREAT | O_WRONLY, 0600); if (fd<0){ printf("There is error code: %d",errno); perror("foo"); } write(fd,"My First System Program\n",24); close(fd); }