This change ensures that /etc/init.d/* scripts are started with
/dev/null as stdin. This is useful in cases where an init.d script
reads (e.g. by mistake) from stdin, which a user can perceive as if
some characters typed into shell on serial console are "eaten" by
something else (i.e. by the init.d script running on background). This
is very annoying, because each character needs to be pressed several
times before it appears on the screen.
Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
return;
}
close(pipefd[0]);
+
+ int devnull = open("/dev/null", O_RDONLY);
+ dup2(devnull, STDIN_FILENO);
dup2(pipefd[1], STDOUT_FILENO);
dup2(pipefd[1], STDERR_FILENO);
+ if (devnull > STDERR_FILENO)
+ close(devnull);
+
execlp(s->file, s->file, s->param, NULL);
exit(1);
}