commit d9f5d29dda4972b80d387929b8f196894e26a1bb
parent 8aea8a33a414d50f922f0b0847426733a8f70e4a
Author: night0721 <[email protected]>
Date: Tue, 6 Feb 2024 18:58:47 +0000
optimizations
Diffstat:
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/commands.c b/commands.c
@@ -164,10 +164,8 @@ int execute(char **args) {
}
}
- pid_t pid, wpid;
+ pid_t pid = fork();
int status;
-
- pid = fork();
if (pid == 0) {
// Child process
if (execvp(args[0], args) == -1) {
@@ -181,7 +179,7 @@ int execute(char **args) {
} else {
// Parent process
while (!WIFEXITED(status) && !WIFSIGNALED(status)) {
- wpid = waitpid(pid, &status, WUNTRACED); // wait child to be exited to return to prompt
+ waitpid(pid, &status, WUNTRACED); // wait child to be exited to return to prompt
}
}