I've been tasked to create a C shell for one of my classes at school. At this time, I am able to execute generic commands in my shell. For examples: ls -al, mv, cp, cd, pwd, etc all work. But it is time to work on the more difficult parts of the assignment. I have been in structured that I am supposed to be able to handle the 'bg' and 'fg' commands.
I am not sure where to begin on this. Perhaps someone can point me in the right directions. I shall, for you, write down my thoughts about this:
In my shell, if the user types program &, it shall start it in the bg list. Now, this means, that, I will fork off the new program. Then, I must place it in the background list and return control to the shell. Then, when the user types fg jobid, it will switch the terminal to the indicated job. I do not know how to place the program into the bg list, or even what to place in the list. The PID? Some sort of reference?? With fg, how do I switch control from the bg process and make it take control of stdin or the terminal in general?
The jobs command also does not report the bg jobs if it is started with 'program &' in my command line.
As one can see, I do not know where to really begin.
Thank you for the assistances.