}
// Send the log message
- if (fd)
+ if (fd >= 0)
vdprintf(fd, format, args);
}
int* fd_write = &(*fds)[1];
// Close the write end of the pipe
- if (*fd_write) {
+ if (*fd_write >= 0) {
close(*fd_write);
*fd_write = -1;
}
// Return the read end
- return *fd_read;
+ if (*fd_read >= 0)
+ return *fd_read;
+
+ return -1;
}
static int pakfire_jail_get_pipe_to_write(struct pakfire_jail* jail, int (*fds)[2]) {
int* fd_write = &(*fds)[1];
// Close the read end of the pipe
- if (*fd_read) {
+ if (*fd_read >= 0) {
close(*fd_read);
*fd_read = -1;
}
// Return the write end
- return *fd_write;
+ if (*fd_write >= 0)
+ return *fd_write;
+
+ return -1;
}
static int pakfire_jail_log(struct pakfire* pakfire, void* data, int priority,
.flags = flags,
.pipes = {
- .stdin = { -1, -1 },
- .stdout = { -1, -1 },
- .stderr = { -1, -1 },
+ .stdin = { -1, -1 },
+ .stdout = { -1, -1 },
+ .stderr = { -1, -1 },
+ .log_INFO = { -1, -1 },
+ .log_ERROR = { -1, -1 },
+ .log_DEBUG = { -1, -1 },
},
.communicate = {