if (fd < 0) {
if (fd != -ENOENT)
_W("sd_journal_stream_fd() is failed. error(%d)", fd);
- return fd;
+ fd = open(PATH_DEV_NULL, O_WRONLY | O_NOCTTY);
+ if (fd < 0) {
+ ret = -errno;
+ _E("open(%s) is failed. errno(%d)",
+ PATH_DEV_NULL, errno);
+ close(STDOUT_FILENO);
+ return ret;
+ }
}
ret = dup2(fd, STDOUT_FILENO);
- if (ret < 0)
- _W("dup(%d, 1) is failed. errno(%d)", fd, errno);
+ if (ret < 0) {
+ ret = -errno;
+ _E("dup(%d, 1) is failed. errno(%d)", fd, errno);
+ close(STDOUT_FILENO);
+ }
close(fd);
return ret;
if (fd < 0) {
if (fd != -ENOENT)
_W("sd_journal_stream_fd() is failed. error(%d)", fd);
- return fd;
+ fd = open(PATH_DEV_NULL, O_WRONLY | O_NOCTTY);
+ if (fd < 0) {
+ ret = -errno;
+ _E("open(%s) is failed. errno(%d)",
+ PATH_DEV_NULL, errno);
+ close(STDERR_FILENO);
+ return ret;
+ }
}
ret = dup2(fd, STDERR_FILENO);
- if (ret < 0)
- _W("dup(%d, 2) is failed. errno(%d)", fd, errno);
+ if (ret < 0) {
+ ret = -errno;
+ _E("dup(%d, 2) is failed. errno(%d)", fd, errno);
+ close(STDERR_FILENO);
+ }
close(fd);
return ret;