What happens when you type ls -l in the shell ?

Generally:

What really happens ?

The getline() Function:

getline(&buffer,&size,stdin);
  1. The number of characters read, on success, without including the terminating null byte of the string.

Parsing The User Input:

ls -la /
$  ls       -la      /
[ls][-la][/]

Execution:

  • If the return value is 0 the program executes in the new child process.
  • If the return value is greater than zero, the program executes in the parent process and the return value is the process ID (PID) of the created child process.
  • On failure fork returns -1.
$> echo $PATH
/bin:/usr/bin:/usr/local/bin

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store