r/cprogramming • • Oct 16 '26

How important is knowing syscalls in C?

Hello, idk if its just me I have been trying to get more and more into C but every video or concept or project I see people bring out 3 different syscalls that I have never heard of (that's a bit exaggerating but you know what I mean)

Am i supposed to know all of them? Memorise them?

Is there something I'm missing in terms of these bc I even realised they can be up to 500 different ones which is a lot to memorise, and even so how should I start learning them?

16 Upvotes

29 comments sorted by

6

u/pjl1967 Oct 16 '26 edited Oct 16 '26

... I have been trying to get more and more into C but every video or concept or project I see people bring out 3 different syscalls that I have never heard of ...

Perhaps instead of watching various videos with varying levels of focus, detail, quality, and accuracy, just pick a good book on C.

Am i supposed to know all of them? Memorise them?

No and no. For the details of any syscall, that's what man pages are for. BTW, a good book will also hopefully list only those syscalls you need to know about since you're more likely to encounter the often-used ones.

1

u/DryAdministration158 Oct 16 '26

I mean I read the "hole book of C" and it did help a lot but not with syscalls that much

About different resources , I get it but I just had this question that are syscalls a part of this language that someone who wants to get good at should learn?

And yes I am getting more and more comfortable with man pages, my problem is that there are tons of syscall functions I don't even know exist so how am I supposed to start reading their man page?

4

u/pjl1967 Oct 16 '26

... are syscalls a part of this language that someone who wants to get good at should learn?

It depends. If you're mainly going to program on Windows, then there's little point in learning about Unix system calls. If you're mainly going to program for Unix, then you should probably learn some syscalls, but just that they exist. As I said, you can always man for details.

... there are tons of syscall functions I don't even know exist so how am I supposed to start reading their man page?

I've been doing C since the 1980s and there are syscalls I don't even know exist. Usually, you need to use a syscall because (1) the C standard simply doesn't provide a function to do what you want to do or (2) you need to take advantage of some high-performance yet platform-specific syscall to do what you want to do.

If you're getting done what you want to get done, then I wouldn't worry about it. These days, you can always describe a problem to AI and it may mention specific syscalls in its answer. Then you know their names. Then you can read their manual pages.

1

u/DryAdministration158 Oct 16 '26

Well yeah you are right I can search for it I guess I was looking for an answer for a situation where I can't search or Google or use an llm but I guess you are right if I'm doing a specific concept sooner or later the syscall necessary for it would pop up

1

u/Paul_Pedant 23d ago

I think you might be confusing syscalls with library calls. They look pretty similar because (at the C level) they look exactly like your own function calls.

Libraries exist because it avoids several million people writing (and supporting and fixing and documenting) different versions of a bunch of stuff.

Syscalls exist because there are some functionalities that need to be outside any individual process (because they share resources between different processes), or are just too unsafe to be built into individual programs.

Neither class is actually a C language feature, They are just a phone-a-friend feature for which the compiler fakes them up like C functions. In 45 years I doubt I have used more than 20% of the available syscalls or libraries.

5

u/nwah Oct 16 '26

off topic, but “memorise” is the standard British spelling so doesn’t need a snide “[sic]”

3

u/pjl1967 Oct 16 '26

In hindsight, you're right — removed.

1

u/nwah Oct 16 '26

I don’t like it either, but I have a lot of UK colleagues so I’ve had to learn to live with it

37

u/mrtlo Oct 16 '26

Knowing C, and knowing "syscalls", would be separate topics IMHO

3

u/ripulejejs Oct 16 '26

what's your usecase?

most people hide behind the c standard library, or some higher abstraction.

so why not just do that? if you use manual syscalls, your code won't be portable between OS-es unless you spend a lot of extra time dealing with that.

1

u/DryAdministration158 Oct 16 '26

I don't have a specific use case but for the sake of argument let's say cybersecurity, every video I watch about some parts uses some syscalls and half of the time I have never even seen that syscall in my life, for example a Linux container, a terminal text editor, a simple database , a webcrawler etc

2

u/orange_oki Oct 16 '26 edited Oct 16 '26

Syscalls are used to switch from user space to kernel space.

Those syscalls are hidden in malloc, fopen and in os specific libraries.

C is portable, so you actually have no syscalls in the standard library...

You can look at the malloc implementation in small glibc replacement...

https://github.com/pts/minilibc686/blob/master/src/malloc_simple_unaligned_linux.nasm

And the actual syscall in line 50.

https://github.com/pts/minilibc686/blob/master/src/syscall3_linux.nasm

2

u/orange_oki Oct 16 '26 edited Oct 16 '26

And for Cybersecurity you almost always need access to the kernel to install some function hooks. Have just found:

https://github.com/proxytype/kprobes-hooks/

😊

https://youtube.com/shorts/ih8X6gFhWJk

1

u/MonkeySmart409 Oct 16 '26

I think you are weirdly obsessing over "sys calls"-  which don't actually have anything to do with the C language.

They are a mechanism by which software can interact with their operating environment-  but they are generally implemented in a library that abstracts and hides the fact that you are even using a system call mechanism.   

11

u/SmokeMuch7356 Oct 16 '26

Am i supposed to know all of them? Memorise them?

Know where to look them up if or when you actually need them. You'll memorize the stuff you use every day; for everything else, that's why man pages exist.

1

u/Ratfus Oct 16 '26

Today, looking them up is basically googling/using AI? Kinda depressing honestly. I suppose, you still need to understand what you're looking up.

4

u/SmokeMuch7356 Oct 16 '26

Man pages predate both AI and Google.

1

u/Love_Buny8 Oct 20 '26

its less about memorizing and more about understanding whats available and when to consult the docs

3

u/zhivago Oct 17 '26

Syscalls are not part of C.

Learn them like any other API.

2

u/SuperBoysenberry3660 Oct 16 '26 edited Oct 16 '26

There is a libc library with functions for c language (available on Linux and Windows). Syscalls is interface of operating system - on Linux there are linux syscalls (you can use these on Linux from c). On Windows you have some platform library like Win32 - to access platform/os functionality (you can use it on windows from c).

2

u/pjl1967 Oct 16 '26

Sorry for the separate reply, but — and to muddy the water even further — there's the C standard library, POSIX, and syscalls. Many syscalls are part of POSIX, but not all, e.g., Linux-specific ones.

Learning POSIX is more important than learning non-POSIX, platform-specific syscalls.

2

u/Runt1m3_ Oct 16 '26

Only if you require it or are doing lower level stuff, you have the libc as an abstraction already.

Still it's fun to sometimes read syscall tables and messing with them using assembly hahahah

1

u/Ratfus Oct 16 '26

You like pain and suffering as well?

Not even I like that much pain. I'll simply get my atiny to blink a led on and off in assembly. None of this loading 60+ registers to print a text.

2

u/serge-mv Oct 16 '26

It depends on what software you are writing and the OS you are writing it for. Syscalls are OS specific (mostly). So using them will make your program less portable, if you care about it. On the other hand, maybe you are writing a system tool for a particular OS, then you kinda have to know them.

In general case, you are better of either using build-in libraries or external ones.

2

u/DumDee-Dum Oct 17 '26

Not at all no one can memorise all syscalls and they are even different from every OS so definitely not

If you need one you will constantly run into it and so you will naturally memorise it just like you memorise standard functions like printf

Personally I write bare-metal code for embedded systems and haven’t used syscalls because I work with devices that don’t even have an OS! However, other embedded developers use an OS and so they need certain functions that are common for them

In short: you can be an excellentC developer without syscalls. And if your line of work requires you to know some then you pick them up as you go

2

u/TheChief275 Oct 19 '26

Not at all important. Unless you want something obscure and non-portable, just stick to the functions defined in <unistd.h>. These are lightly abstracted syscalls, but the benefit is that even OS's like Windows define a compatibility function for a large portion of these functions

0

u/esaule Oct 17 '26

let me put it this way, if I am interviewing a C programmer and he doesn't know the standard syscall; I'm not hiring them!