Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <unistd.h>
- int main(){
- char *input[20];
- char *parsed;
- char *command;
- int index = 0;
- char* command2[4];
- char* seperator = " ";
- char c;
- int size;
- int stat_loc;
- pid_t child_pid;
- char** args;
- while(1){
- printf("MYSHELL-->");
- args = Readline();
- if (strcmp(command2[0], "cd")== 0){
- perror(command2[1]);
- }
- if (strcmp(command2[0], "logout\n") == 0){
- printf("Wollen Sie sich wirklich ausloggen? j/n?: ");
- c = getchar();
- if (c = 'j'){
- return 0;
- }
- }
- // for (size_t i = 0; i < sizeof(command2); i++){
- // if (strcmp(command2[i], "&\n")==0){
- // printf("blalala\n");
- // break;
- // }
- //}
- //free(input);
- //free(command2);
- }
- return 0;
- }
- char** Readline(void){
- char **command;
- int index;
- char *seperator= " ";
- char* input[20];
- char* parsed;
- fgets(input, 20, stdin);
- printf("\n");
- parsed = strtok(input, seperator);
- while (parsed != NULL) {
- command[index] = parsed;
- index++;
- parsed = strtok(NULL, seperator);
- }
- command[index] = NULL;
- return command;
- }
- int CreateProcesses
- child_pid = fork();
- if (child_pid == 0 ){
- printf("Kindprozess: %d\n", getpid());
- }
- else {
- printf(child_pid);
- printf("\n");
- waitpid(child_pid, &stat_loc, WUNTRACED);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement