Skip to content
Advertisement

When should syscall function be used instead of glibc wrapper?

man page of syscall says, “it is useful when there is no wrapper function in c library”. If wrapper function is available, Is it always better to use wrapper function ? If not, when should prefer syscall over it?

Advertisement

Answer

Never.

The only situation where you should ever consider using syscall() is to invoke a system call that doesn’t have a wrapper in your C library. It has absolutely no advantages over a libc wrapper, and many disadvantages. (For instance: It is less clear, non-portable, and bypasses compile-time checks on the number and type of arguments.)

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement