Make sure that you are compiling with all warnings enabled with the -Wall flag like this:
gcc -Wall -g myshell.c -o myshellMost warnings should really be errors, and unfortunately, they are worded in a way that is technically precise, but often confusing. Here are some common kinds of warnings:
myshell.c:70: warning: implicit declaration of function `strsignal'The warning "implicit declaration" technically means that you are trying to use a function that was never declared to the compiler, so it doesn't know how to invoke it. Practically speaking, it means that you are missing the proper #include directive. Look up the man page for the given function to figure out what #include to add to your program.
myshell.c:35: warning: format argument is not a pointer (arg 3)This argument means that you have a problem with a printf statement. The "format argument" is the string that contains the percent codes. Make sure that each of your percent codes match up with the rest of the arguments.
myshell.c:4: warning: control reaches end of non-void functionThis warning tells you that your function is lacking a return statement. This is bad, because the function might return any arbitrary value, which is probably not what you want. If you deliberately want a function that returns no value, declare it as a void function.
The run command should only wait for the particular process that was just started. The wait system call will not help you here, because it waits for any finished process. Instead, use the waitpid system call, which can wait for one particular process.
You will need to do a little translation before passing the arguments to execvp. After using strtok to split up the line, you will have something like this:
words[0] = "start" words[1] = "emacs" words[2] = "doc.txt" words[3] = 0;Now, inside of your shell, you will examine words[0] to figure out whether to do a start, a wait, or something else. If you are doing a start, then, you need to assemble an array that looks like this:
args[0] = "emacs" args[1] = "doc.txt" args[2] = 0;Then, you can simply call execvp(args[0],args);