add launch section to report
This commit is contained in:
20
doc/code/launch.txt
Normal file
20
doc/code/launch.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
void launch_program(StringArray *args) {
|
||||
pid_t child = 0;
|
||||
|
||||
child = fork();
|
||||
|
||||
if (child == 0) {
|
||||
if (execvp(args->array[0], args->array) == -1) {
|
||||
fprintf(stderr, "%s: command not found\n", args->array[0]);
|
||||
free_string_array(args);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
else if (child < 0) {
|
||||
perror("fork");
|
||||
}
|
||||
else {
|
||||
int child_status;
|
||||
waitpid(child, &child_status, 0);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user