From d9f5d29dda4972b80d387929b8f196894e26a1bb Mon Sep 17 00:00:00 2001 From: night0721 Date: Tue, 6 Feb 2024 18:58:47 +0000 Subject: [PATCH] optimizations --- commands.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/commands.c b/commands.c index 4ecc4e9..430ddf6 100644 --- 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 } }