
Many Microsoft employees have contributed to the Windows Subsystem for Linux, this commit is the result of their work since 2016. The entire history of the Windows Subsystem for Linux can't be shared here, but here's an overview of WSL's history after it moved to it own repository in 2021: Number of commits on the main branch: 2930 Number of contributors: 31 Head over https://github.com/microsoft/WSL/releases for a more detailed history of the features added to WSL since 2021.
1.2 KiB
Session leader
A session leader is a linux process, which is forked from init after receiving a LxInitMessageCreateSession
message (see src/linux/init.cpp
)
Creating linux processes
Session leaders are used to create linux processes on behalf of the user. Each linux session leader is associated to a Windows console.
To create a user process, wslservice.exe sends a LxInitMessageCreateProcess
message (WSL1) or a LxInitMessageCreateProcessUtilityVm
message (WSL2), which contains details about the process to create such as:
- Command line
- Current directory
- Environment variables
- User name
Creating a WSL1 process
When running in a WSL1 distribution, the session leader forks(), and uses the child process to exec()
into the user linux process. Before calling exec()
, child configures various settings such as:
- The user and group id
- The current directory
- The standard file descriptors (stdin, stdout, stderr)
Creating a WSL2 process
When running in a WSL2 distribution, the session leaders forks() to create a relay process, which is responsible for creating the user process and relaying its output back to wsl.exe