strace cmd tells us all activities behind the command.
This link has detailed discussion on
Hope the discussion could be helpful.
if you only type "ls", it will directly show you the current directory's files and subdirectories.
Parent process forked a child process and the child process starts executing ls code while the parent process waits for the child process to die. Basically, child process calls exec Function which will destroy the current address space of the child process and new address space is built which will have code of ls command. After executing the code of ls command, child process calls exit and turns to zombie process which will be reaped by the parent process.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.