mirror of
https://github.com/systemd/systemd.git
synced 2024-10-27 18:55:40 +03:00
log: never close file descriptors < 3
This commit is contained in:
parent
710bd14347
commit
c8513d54d2
@ -50,8 +50,10 @@ void log_close_console(void) {
|
||||
if (console_fd < 0)
|
||||
return;
|
||||
|
||||
if (getpid() == 1 || console_fd != STDERR_FILENO) {
|
||||
close_nointr_nofail(console_fd);
|
||||
if (getpid() == 1) {
|
||||
if (console_fd >= 3)
|
||||
close_nointr_nofail(console_fd);
|
||||
|
||||
console_fd = -1;
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ static void install_crash_handler(void) {
|
||||
static int make_null_stdio(void) {
|
||||
int null_fd, r;
|
||||
|
||||
if ((null_fd = open("/dev/null", O_RDWR)) < 0) {
|
||||
if ((null_fd = open("/dev/null", O_RDWR|O_NOCTTY)) < 0) {
|
||||
log_error("Failed to open /dev/null: %m");
|
||||
return -errno;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user