1 /* 2 * do_bgfg - Execute the builtin bg and fg commands 3 */ 4 void do_bgfg(char **argv) 5 { 6 return; 7 }
Example
tsh> jobs [1] (31251) Stopped myspin 20 tsh>
The process executing the program "myspin" is stopped in the background.
It has process id (pid) 31251 and job id (jid) 1.
The shell is waiting for a new command while "myspin" is stopped.
The fg or the bg command will cause myspin to continue running.
The fg command will cause myspin to run as the foreground process - the shell will wait for it to finish.
The bg command will cause myspin to run, but still in the background - the shell will not wait, but will print the prompt to read another command while myspin runs.