Advertisement

questions

Started by June 24, 2004 01:23 AM
6 comments, last by BitBlt 20 years, 2 months ago
hi! im a computer science student and i need some sort of help... we were asked to connect to other computer professionals in the world to ask questions... like ho do i make a shell? a unix shell... i hope somebody will reply... who i can get in touch with... :) tnx!
The simplest shell is something that just accepts input from the terminal and executes the programs requested. Of course, there are a lot of features that are helpful to have, such as a current user/working directory/et cetera indicator, the ability to pass arguments to the programs invoked, the ability to pipe programs into each other and redirection to files, tab completion, and so on.

For the minimal shell, you'll need to lookup fork and exec. You'll need to write a simple parser for command line arguments. For piping and redirection you'll want to lookup pipe and dup2.
Advertisement
how about deadlocks? what about them? how to detect them and recover...
I had to do this for an Operating Systems course. The meat of your program is get the command line (parse it for pipes, redirects, etc.), fork (which creates an identical copy of the program that even continues running from the same location in code), determine whether you are the child or parent (since after you call fork, you must test to see which you are!), parent waits for child to finish (unless process is put in the background, '&' in bash and other variants), and the child calls exec, which overwrites its own process space with the process being exec'ed.

Also, shells have a few built in commands. For instance, ls and top are their own programs, but cd is built into the shell.

Good luck.
tnx bitbit! anybody here knows someone who have already written a program for shells? i was hoping i could get a contact...
Quote: Original post by BitBlt
I had to do this for an Operating Systems course.


Man, lucky bastards... Sounds easy... We had to write a kernel... :P
Advertisement
Quote: Original post by jcka
tnx bitbit! anybody here knows someone who have already written a program for shells? i was hoping i could get a contact...
bash (and for that matter, all of the common shells) is open source, though those are a bit complicated. You may want to browse through the code.
Zorx (a Puzzle Bobble clone)Discontinuity (an animation system for POV-Ray)
Quote: Original post by Spoonster
Quote: Original post by BitBlt
I had to do this for an Operating Systems course.


Man, lucky bastards... Sounds easy... We had to write a kernel... :P


Dang, write a kernel? This was our first project, so it was pretty easy. Later on we added system calls to the kernel, wrote modules, etc.

This topic is closed to new replies.

Advertisement