Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1.  
  2. #include <unistd.h>
  3. #include <stdlib.h>
  4. #include <sys/types.h>
  5. #include <sys/wait.h>
  6. #include <string.h>
  7. #include <stdio.h>
  8.  
  9. int main(int argc, char *argv[])
  10. {
  11.     int id, s;
  12.     int bk = 1;
  13.     char input[100];
  14.     while (bk = 1)
  15.     {
  16.         printf("user@ubuntu: ");
  17.         scanf("%s", input);
  18.         int ex = strcmp(input, "exit");
  19.         if (ex == 0)
  20.         {
  21.             break;
  22.         }
  23.         else
  24.         {
  25.             id = fork();
  26.             if (!(id == 0))
  27.             {
  28.                 wait(&s);
  29.             }
  30.             else
  31.             {
  32.                 execlp(input, input, NULL);
  33.             }
  34.         }
  35.     }
  36.    
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement