I want to write a shell in the Linux operating system with the C language.
What is the name of the libraries and functions to use in this project?
thank you.
I want to write a shell in the Linux operating system with the C language.
What is the name of the libraries and functions to use in this project?
thank you.
You will probably want, at the very least:
The Single UNIX Specification Man Pages are a good resource for any additional functionality needed.
I don't understand your question. You are starting a new thing, you can use whatever name you want. And the notion of Project is usually specific to some IDEs.
To code a shell, you first must know well the C programming language, and understand well several important Linux system calls (like fork, execve, pipe, chdir, dup etc.). So read a good textbook on these first. The system calls are available thru the standard C library, you don't need to link an extra one.
And probably, studying the source code of small shells (like sash) would help you a lot.
Actually, that's an interesting question and it could be a good exercise for something to know the IO mechanism of Unix. As you might know, Shell is responsible for interpreting Input , invoking the system calls and displaying the output. The program as such runs on top of the kernel. So, the exercise might give a lot of info on process execution family such as exec*.
Here is one tutorial covering it for you in C and this one in Python would help you design a quick prototype for understanding.
Unfortunately, there isn't some magical emulateShell() API call you can make for this, you are going to need to look into (in great depth) things like exec, fork, popen, signal/sigaction and a host of other process control things.
In addition, you'll probably need to get involved with terminal handling and so forth, things like fcntl and ioctl.
It's not really a subject that can be covered comprehensively is an answer box this size. I would suggest trying to break it down in smaller jobs so as to make your (and our) job easier.
Perhaps start with a simple program that accepts commands from the user and breaks them down into tokens for execution. That would be a good first step.