dev_null = open ("/dev/null", O_RDWR);
if (dev_null == -1) {
- syslog (LOG_ERR, "Error: couldn't failed to open /dev/null: %s", strerror (errno));
+ syslog (LOG_ERR, "Error: couldn't open /dev/null: %s", strerror (errno));
return -1;
}
if (dup2 (dev_null, STDIN_FILENO) == -1) {
+ close (dev_null);
syslog (LOG_ERR, "Error: couldn't connect STDIN to /dev/null: %s", strerror (errno));
return -1;
}
if (dup2 (dev_null, STDOUT_FILENO) == -1) {
+ close (dev_null);
syslog (LOG_ERR, "Error: couldn't connect STDOUT to /dev/null: %s", strerror (errno));
return -1;
}
if (dup2 (dev_null, STDERR_FILENO) == -1) {
+ close (dev_null);
syslog (LOG_ERR, "Error: couldn't connect STDERR to /dev/null: %s", strerror (errno));
return -1;
}