Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <unistd.h>
  4. #include <sys/wait.h>
  5. #include <string.h>
  6. #include <stdlib.h>
  7. int main(int argc, char **args){
  8.  
  9. while (1){
  10.         char linia[50];
  11.         char **args[50];
  12.         for(int i=0; i<50; i++)
  13.                 linia[i]=' ';
  14.         printf("%s\n",">");
  15.         fgets(linia,50,stdin);
  16.         while (args != NULL)
  17.         {
  18.         printf("%s\n", args);
  19.         args = strtok(NULL, " , ");
  20.         }
  21.  
  22.         if(strcmp(args[0],"exit")==0){
  23.                 exit(0);
  24.         }
  25.         if (fork() !=0){
  26.                 waitpid(-1, &status,0);}
  27.         else {
  28.                 execvp(args[0],args);
  29.         }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement