Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

435
Views
Are function calls like read() , write() actual system calls in linux?

I have been writing programs in C/C++ that make use of the Linux API and make system calls like fork(),read(),write() etc. Now, I am beginning to wonder if these library functions are actually system calls, or are they some kind of wrapper functions.

What really happens when a program makes a call to write() ? How does this function interact with the kernel ? If this is a wrapper then why do we need it ?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

All such functions are real userspace functions in libc.so that your binary is linked against. But most of them are just tiny wrappers for syscalls which are the interface between the userspace and the kernel (see also syscall(2)).

Note that functions that are purely userspace (like fmod(3)) or do some things in userspace in addition to calling the kernel (like execl(3)) have their manpages in the section 3 while functions that just call the kernel (like read(2)) have them in the section 2.

over 4 years ago · Santiago Trujillo Report

0

using this simple code :

int main()
{
    int f = open("/tmp/test.txt", O_CREAT | O_RDWR, 0666);
    write(f, "hello world", 11);
    close(f);

    return 0;
}

you can use strace to find system calls used in the binary file :

gcc test.c -o test
strace ./test

the result is something like this :

.
.
.
open("/tmp/test.txt", O_RDWR|O_CREAT, 0666) = 3
write(3, "hello world", 11)             = 11
close(3)                                = 0
exit_group(0)                           = ?

as for fork(), it's actually a wrapper around clone() system call

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!