![]() This system call is the first in our case and only, for example: $ strace lsĮxecve("/bin/ls",, ) = 0Įxecve("/bin/echo",, ) = 0Įxecve("/bin/uname",, ) = 0 The execve system call has the following signature: int execve(const char *filename, char *const argv, char *const envp) Īnd executes a program by the given filename, with the given arguments and environment variables. In the end of this process, the shell_execve function calls the execve system call: execve (command, args, env) As I already wrote above, we will not consider all details about things that are not related to the Linux kernel. Makes different checks like do we need to start subshell, was it builtin bash function or not etc. The execute_command function through the chain of the functions calls: execute_command As the reader_loop function made all checks and read the given program name and arguments, it calls the execute_command function from the execute_cmd.c source code file. This function defined in the eval.c source code file and represents main thread loop or in other words it reads and executes commands. ![]() profile and other configuration files Īfter all of these operations we can see the call of the reader_loop function. check that shell running in debug mode.This function makes many different things before the main thread loop of the bash started to work. If you will look on the source code of the bash shell, you will find the main function in the shell.c source code file. The bash shell as well as any program that written with C programming language starts from the main function. My default shell is - bash, so I will consider how do bash shell launches a program. We will not consider in details what does shell do, we will not consider complex cases, for example subshells etc. That's why we will see Linux kernel insides related stuff mostly in this part. But before we will start to consider these interesting things, I want to warn that this book is about the Linux kernel. Let's consider what does occur when we launch an application from the shell, what does shell do when we write program name, what does Linux kernel do etc. As you know, the standard way to launch an application from shell is the following: We just launch a terminal emulator application and just write the name of the program and pass or not arguments to our program, for example: In this part we will consider the way when we just launch an application from the shell. The Linux kernel handles application launch regardless how we do launch this application. ![]() For example we can run a program from the shell or double-click on the application icon. There are many different ways to launch an application from a user perspective. This part will be last part in this chapter and as you can understand from the part's title - we will see what does occur in the Linux kernel when we run our programs. That are related and very similar on system call concept. In the previous part we stopped at the two new concepts: This is the fourth part of the chapter that describes system calls in the Linux kernel and as I wrote in the conclusion of the previous - this part will be last in this chapter. Write and Submit your first Linux kernel Patch How the Linux kernel handles a system call Initialization of external hardware interrupts structures ![]() Implementation of some exception handlers Initialization of non-early interrupt gates Last preparations before the kernel entry pointĬontinue architecture-specific boot-time initializationsĪrchitecture-specific initializations, again.Įnd of the architecture-specific initializations, almost. Video mode initialization and transition to protected mode ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |