Compare commits

...

2 Commits

Author SHA1 Message Date
4dcee8f828
sh: Print "exit" on EOF only when the shell is in interactive mode
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-26 17:29:41 +02:00
84c1871d30
libc: Check if a shell is available if system()'s command argument is NULL 2023-05-26 17:27:37 +02:00
2 changed files with 7 additions and 4 deletions

View File

@ -88,7 +88,7 @@ Result<int> luna_main(int argc, char** argv)
auto cmd = TRY(input_file->read_line());
if (cmd.is_empty())
{
puts("exit");
if (interactive) puts("exit");
break;
}

View File

@ -184,11 +184,14 @@ extern "C"
{
if (!cmd)
{
// FIXME: Check if there is a shell available in the system.
errno = ENOTSUP;
return -1;
struct stat st;
if (stat("/bin/sh", &st) < 0) return 0;
return S_ISREG(st.st_mode);
}
// FIXME: During the execution of system(), SIGCHLD will be blocked, and SIGINT and SIGQUIT will be ignored, in
// the process that calls system().
pid_t child = fork();
if (child == 0)
{