Struggling with Creating a Shell in C -


I am struggling to apply a basic shell. I understand the basic concept and as far as a seg-fault I basically need to apply a shell:

  1. Prompt
  2. Parse input
  3. create argv []
  4. Kanka Kid - & gt; Execvp () Parent - & gt; Waiting / Waiting Period ()

    The code given below is given below and I can not understand what I am doing for my life. I have seen many other places. My initial idea is to do it with strtok (), but I could not despise it.

      int main (int argc, char * argv []) {pid_t pid; Four inputs [100]; Four * p [20]; Int Newforg; Four * s; While (1) {printf ("simple shell"); Fgets (input, 100, stdin); S = Stroke (input, ""); While (P [numofargs]! = NULL) {P [numofargs] = strtok (NULL, ""); numofargs ++; } Pid = fork (); If (pd == 0) {execvp (p [0], p); Lie ("execution failed"); } And waitpad (); } Exit (0); }    

    Note that p is an array of pointers Four . To begin this, is undefined , which means every entry is p [n] (i.e. 20 elements of each p where 0 & lt; = N & lt; 20) Trash is still the first thing you do with it to see if its one object is NULL It is accidentally besides you, you have numofargs , so which element of p are you accessing? Who knows. It's also a crashstick that's ok to start those things.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -