0

Updated:

The internal command was not done as separated process in normal execution because it done with shell.

but what steps are done by bash,if the builtin process was executed to background.

  1. How That process executed without from separate file.

    1. Does creating a file with code of that in built command then execute it?
    2. Or bash execute these command as converting it as bash -c "cd" before execute it?.
  2. why some built-in commands exited instantly without waiting for any input like read&

  3. why The bash provide the PID first, before checking the command (file) was exist.

thank you,

1 Answer 1

4

As you seem to understand, shell built-in functions such as echo are processed by the running shell and therefore do not require a new process to be started in the foreground (normally).

However, if you send them to the background, they need to be controlled by a distinct shell and will consequently start a new shell process with the command in question. This should be fairly easy to observe in bash as sending a process in the background will show the new process id next to the job number such as:

$ echo 'hi' &
[1] 19536
hi

In this case, process 19536 is a new bash instance.

3
  • thanks, Then why the stoped message shown on read builtin comand going to background process. Jul 23, 2016 at 9:00
  • Hmmm. You seem to be confusing concepts. A background process is not stopped, and it also keeps its standard input, output and error unless you redirect them. Jul 23, 2016 at 10:44
  • Thanks, mostly I got confusion on seeing some output's behaviour. Jul 25, 2016 at 3:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.