C File Descriptors: A Novice Dialogue

In the Operating Systems class at my university, one of the projects we have to complete is a Unix shell. It’s a basic shell which should support piping, redirection, inverse redirection, and background processes. Needless to say, this was an immensely interesting and useful project, though sometimes difficult for the unassuming undergrad.

I had completed it in a previous semester, but a friend called on my guidance last semester for implementing pipes and redirection. She contacted me via IM:

Qi: hey Zact
  Zach
 me: zact??
 Qi: lol
  sorry
 me: ha, np

What follows is my attempt at explaining file descriptors, forks, and redirection, without much formal knowledge and not having worked with C in a year. Dijkstra would certainly not approve of such malling of a radical novelty, but my friend was grateful nonetheless and the dialogue does indeed prove to be useful in achieving a basic understanding of the premises of the project (namely, forks and file descriptors.)

Read at your own peril.

To follow along, also have the tutorial code handy.

All of this trouble was not in vain, however:

Qi: THANKS MUCH MUCH MUCH
  i owe you one
  after exams are done
  i'll cook some noodles
  ;)
 me: !!!!!!!!!

I would have been fine with naught, for I gained much from this as well, if not more.