>>108000714
thanks for the answer. Still confused though. This UNIX util is C under the hood so the question still applies, how can this be portable when they're using different syscalls?
#example from "OS: 3EP"
prompt> strace cat foo
...
open("foo", O_RDONLY|O_LARGEFILE)
read(3, "hello\n", 4096)
write(1, "hello\n", 6)
hello
read(3, "", 4096)
close(3)
but when I do it on my Ubuntu server:
$ strace cat foo
openat(AT_FDCWD, "foo", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0664, st_size=6, ...}) = 0
fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
mmap(NULL, 139264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x73e1bbc5f000
read(3, "hello\n", 131072) = 6
write(1, "hello\n", 6hello) = 6
read(3, "", 131072) = 0
munmap(0x73e1bbc5f000, 139264) = 0
close(3)
I can see how both calls are equivalent, but still, why are they so different?