a simple UNIX command interpreter
- Who designed and implemented the original Unix operating system
The original Unix operating system was designed and implemented by Ken Thompson, Dennis Ritchie, and others at Bell Labs in the early 1970s.
- Who wrote the first version of the UNIX shell
The first version of the UNIX shell was written by Ken Thompson.
- Who invented the B programming language (the direct predecessor to the C programming language)
The B programming language, the direct predecessor to the C programming language, was developed by Ken Thompson at Bell Labs in the early 1970s.
- Who is Ken Thompson
Ken Thompson is a computer scientist and one of the pioneers in the field of computer science.Ken Thompson
- How does a shell work
A shell is a command-line interface that allows users to interact with an operating system. It interprets user commands and executes them, facilitating communication between the user and the operating system.
- What is a pid and a ppid
-
PID (Process ID): A number assigned to a running process, used to uniquely identify and manage processes.
-
PPID (Parent Process ID): The PID of the process that spawned the current process. It indicates the parent-child relationship between processes.
Learn about PIDs and PPIDs in this video: Understanding PIDs and PPIDs
- How to manipulate the environment of the current process
In a Unix-like operating system, the environment of a process includes a set of variables that define the environment in which the process runs. These variables can include information such as the user's home directory, the current working directory, and various configuration settings.
- What is the difference between a function and a system cal
- Function:
Scope: Functions are units of code within a program or a module. They are part of the application's source code and are designed to perform a specific task or set of tasks.
Purpose: Functions are used for code organization, modularization, and reusability within a program. They help break down a program into smaller, manageable parts, improving maintainability and readability.
Invocation: Functions are invoked by calling their name within the program. They typically run in user mode, and their execution is managed by the program itself.
- System Call:
Scope: System calls are interfaces provided by the operating system kernel to enable interaction between user-level processes and the operating system. They are part of the operating system's kernel code.
Purpose: System calls provide a way for user-level programs to request services or resources from the operating system, such as file I/O, process creation, and network communication. They serve as a bridge between user space and kernel space.
Invocation: System calls are invoked through a specific interface, often involving interruptmechanisms or special instructions that switch the CPU from user mode to kernel mode. They trigger privileged operations and are used to perform tasks that require kernel-level access.
- How to create processes
In Unix-like operating systems, processes are created using the fork() system call.
Learn about fork() in this video: create processes
- What are the three prototypes of main
In the C programming language, the main function serves as the entry point for the execution of a program. Here are the three common prototypes:
- No Command-Line Arguments:
int main(void);- With Command-Line Arguments:
int main(int argc, char *argv[]);- With Environment Variables:
int main(int argc, char *argv[], char *envp[]);- How does the shell use the PATH to find the programs
The PATH environment variable plays a crucial role in how the shell locates executable programs. When you enter a command in the shell, it searches through directories listed in the PATH variable to find the corresponding executable file. Here's how the process works:
- How to execute another program with the execve system call
The execve system call in Unix-like operating systems is used to execute another program. It replaces the current process image with a new one, loading and executing a different program.
- How to suspend the execution of a process until one of its children terminates
To suspend the execution of a process until one of its children terminates, you can use the waitpid system call in Unix-like operating systems. The waitpid system call allows a parent process to wait for a specific child process to exit or for any child process to exit.
- What is EOF / “end-of-file”?
EOF, or "end-of-file," is a concept used in file input/output operations to indicate the end of the data in a file. It is a special value that signifies that there are no more characters or data to be read from a file.
git clone https://github.com/ANAS-OU/simple_shell.git
- execute this command in your terminal
- to execute using gcc
gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o shell
- run the code
-
./shell -
valgrind --leak-check=full --show-leak-kinds=all -s ./shell
- testing time




