Kernel: Userspace sets the foreground process and Shell handles ^C
This commit is contained in:
@@ -380,10 +380,16 @@ int execute_command(BAN::Vector<BAN::String>& args)
|
||||
if (pid == -1)
|
||||
ERROR_RETURN("fork", 1);
|
||||
|
||||
if (tcsetpgrp(0, pid) == -1)
|
||||
ERROR_RETURN("tcsetpgrp", 1);
|
||||
|
||||
int status;
|
||||
if (waitpid(pid, &status, 0) == -1)
|
||||
ERROR_RETURN("waitpid", 1);
|
||||
|
||||
if (tcsetpgrp(0, getpid()) == -1)
|
||||
ERROR_RETURN("tcsetpgrp", 1);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -489,6 +495,9 @@ int main(int argc, char** argv)
|
||||
{
|
||||
argv0 = argv[0];
|
||||
|
||||
if (signal(SIGINT, [](int) {}) == SIG_ERR)
|
||||
perror("signal");
|
||||
|
||||
if (argc >= 2)
|
||||
{
|
||||
if (strcmp(argv[1], "-c") == 0)
|
||||
@@ -599,6 +608,12 @@ int main(int argc, char** argv)
|
||||
fflush(stdout);
|
||||
}
|
||||
break;
|
||||
case '\x03': // ^C
|
||||
fputc('\n', stdout);
|
||||
print_prompt();
|
||||
buffers[index].clear();
|
||||
col = 0;
|
||||
break;
|
||||
case '\n':
|
||||
fputc('\n', stdout);
|
||||
if (!buffers[index].empty())
|
||||
|
||||
Reference in New Issue
Block a user