Skip to content
Snippets Groups Projects
Commit b046ce02 authored by 김기훈's avatar 김기훈
Browse files

process creation

parent c5c3448d
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include <linux/limits.h>
......
......@@ -2,6 +2,15 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <errno.h>
#include <pthread.h>
#include "commands.h"
#include "built_in.h"
......@@ -49,6 +58,23 @@ int evaluate_command(int n_commands, struct single_command (*commands)[512])
return 0;
} else if (strcmp(com->argv[0], "exit") == 0) {
return 1;
}
else if(com->argv[0] > 0) {
pid_t pid;
pid = fork();
switch(pid)
{
case -1 :
printf("fail\n");
case 0 :
execv(com->argv[0], com->argv);
printf("exec fail\n");
default :
wait((int*)0);
printf("complete\n");
exit(0);
}
} else {
fprintf(stderr, "%s: command not found\n", com->argv[0]);
return -1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment