I’m trying to code a simple shell by C. But i can’t using sys/wait.h. My code same that:
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
int main(void) {
char command[BUFSIZ];
int status;
pid_t pid;
for(;;) {
printf("simpsh: ");
if(fgets(command, sizeof(command), stdin) == NULL) {
printf("\n");
return 0;
}
command[strlen(command) - 1] = '\0';
if((pid = fork()) == 0)
execlp(command, command, 0);
while(wait(&status) != pid)
continue;
printf("\n");
}
}
I’m using dev-C++ and result is:
[Error] sys/wait.h: No such file or directory
What wrong in here? And if anyone have some suggestions for me to create a simple shell by C or C++ please give me some links or codes. thanks!
You need to sign in to view this answers
Leave feedback about this