libc: Check if a shell is available if system()'s command argument is NULL

This commit is contained in:
apio 2023-05-26 17:27:37 +02:00
parent 3a51807fa6
commit 84c1871d30
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -184,11 +184,14 @@ extern "C"
{ {
if (!cmd) if (!cmd)
{ {
// FIXME: Check if there is a shell available in the system. struct stat st;
errno = ENOTSUP; if (stat("/bin/sh", &st) < 0) return 0;
return -1; 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(); pid_t child = fork();
if (child == 0) if (child == 0)
{ {