diff --git a/userspace/Shell/main.cpp b/userspace/Shell/main.cpp index 6b9c2171..feebfe41 100644 --- a/userspace/Shell/main.cpp +++ b/userspace/Shell/main.cpp @@ -612,7 +612,7 @@ pid_t execute_command_no_wait(BAN::Vector& args, int fd_in, int fd_ perror("setpgid"); exit(1); } - if (tcsetpgrp(0, getpgrp()) == -1) + if (isatty(0) && tcsetpgrp(0, getpgrp()) == -1) { perror("tcsetpgrp"); exit(1); @@ -644,7 +644,7 @@ int execute_command(BAN::Vector& args, int fd_in, int fd_out) if (waitpid(pid, &status, 0) == -1) ERROR_RETURN("waitpid", 1); - if (tcsetpgrp(0, getpgrp()) == -1) + if (isatty(0) && tcsetpgrp(0, getpgrp()) == -1) ERROR_RETURN("tcsetpgrp", 1); if (WIFSIGNALED(status)) @@ -722,7 +722,7 @@ int execute_piped_commands(BAN::Vector>& commands) exit_codes[i] = WEXITSTATUS(status); } - if (tcsetpgrp(0, getpgrp()) == -1) + if (isatty(0) && tcsetpgrp(0, getpgrp()) == -1) ERROR_RETURN("tcsetpgrp", 1); return exit_codes.back();