Your shell cannot run the lst command. Therefore, you get the error Can't exec.... The $output variable is empty, that's why you get the warning and no output. The documentation of fork says you cannot share a variable between the parent and child process.