File tree Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -119,4 +119,35 @@ char **shell_split_line(char *line)
119
119
return tokens ;
120
120
} /* I definetively should study this function to know exactly how it works, and not just what it does.. :/ */
121
121
122
- /* CONTINUE: How shells start processes */
122
+ int lsh_launch ( char * * args )
123
+ {
124
+
125
+ pid_t pid , wpid ;
126
+ int status ;
127
+
128
+ pid = fork ();
129
+ if (pid == 0 )
130
+ {
131
+ if (execvp (args [0 ], args ) == -1 ) /* take a time after and understand this function */
132
+ {
133
+ perror ("lsh" );
134
+ }
135
+ exit (EXIT_FAILURE );
136
+ }
137
+ else if (pid <= 0 )
138
+ {
139
+ perror ("lsh" );
140
+ }
141
+ else
142
+ {
143
+ do
144
+ {
145
+ wpid = waitpid (pid , & status , WUNTRACED );
146
+ }
147
+ while (!WIFEXISTED (status ) && !WIFSIGNALED (status ));
148
+ }
149
+ return 1 ;
150
+ }
151
+
152
+
153
+ /* CONTINUE: SHELL BUILTINS */
You can’t perform that action at this time.
0 commit comments