On Tue, Nov 12, 2024 at 11:24:59 +0100,
[email protected] wrote:
On Tue, Nov 12, 2024 at 10:08:18AM +0000, Corey wrote:
Hello
Do you know in C language what's the better way to get the info like the output by lsb_release?
$ lsb_release -cd
Description: Ubuntu 22.04.3 LTS
Codename: jammy
i know there is system call. but is there a native way?
I don't think there is a special system call for that. Have you had a
look at the command itself? It is a shell script, and looks pretty
pedestrian to me (at first sight, granted).
I think Corey might be confused about the term "system call".
Most people use "system call" to mean an invocation of a subroutine
within the kernel. These system calls are documented in section 2 of
the man pages, so e.g. "read(2)" is a system call that reads bytes
from an open file descriptor.
For the official explanation of a system call, see <
https://manpages.debian.org/bookworm/manpages/intro.2.en.html>
or "man 2 intro" if you have this section installed locally.
I *suspect* that Corey thought "system call" meant the use of the
system(3) library function, which executes a shell command.
As tomas points out, lsb_release is a relatively short shell script,
and you can read it to see what it's doing. Ultimately, it's reading
data from /etc/os-release (or /usr/lib/os-release), parsing it, and
printing pieces of it.
You could write a C program to do the same steps.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)