2 ms·
The link posted by oomo contains (in French) an explanation about why it just works and is clean, general and guaranteed: from the page "les syscall ne peuvent
by s_gourichon 6y ago
The link posted by oomo contains (in French) an explanation about why it just works and is clean, general and guaranteed:
from the page "les syscall ne peuvent pas segfault
[dek\] Donc tous ceux qui acceptent une adresse
[dek\] Sont obligées de checker qu’elles est valide
[dek\] Et retournent EFAULT en cas d’erreur"
In English: "syscalls cannot segfault, so all that accept an address (as parameter) have to check if it is valid and return EFAULT in case of error."
(Since C code actually calls libc not system calls directly, this rationale fails on calls that do something on pointers before calling the actual kernel system call.)
Also, given the time cost of making a system call, one has to has an approach finer than "pay a system call for each byte to write" if there are many.
Anyway, TL;DR : it's not a dirty hack, it has some general validity!