summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyo Nakamura <upa@haeena.net>2023-03-15 00:39:56 +0900
committerRyo Nakamura <upa@haeena.net>2023-03-15 00:39:56 +0900
commit4e80b05da763f6ab10e2885a164856cc7afd8fb9 (patch)
treee39e9442eb0f5a473c95f7cdc3d46d1a5a47b0d0
parent98eca409af5380f9dd8ec31e0a2f7fef7d2820bf (diff)
do not fdopen(msg_fd) if msg_fd < 0
-rw-r--r--src/mscp.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/mscp.c b/src/mscp.c
index 08b19c4..17fd542 100644
--- a/src/mscp.c
+++ b/src/mscp.c
@@ -240,11 +240,14 @@ struct mscp *mscp_init(const char *remote_host, int direction,
goto free_out;
}
m->direction = direction;
- m->msg_fp = fdopen(o->msg_fd, "a");
- if (!m->msg_fp) {
- mscp_set_error("fdopen failed: %s", strerrno());
- goto free_out;
- }
+ if (o->msg_fd > -1) {
+ m->msg_fp = fdopen(o->msg_fd, "a");
+ if (!m->msg_fp) {
+ mscp_set_error("fdopen failed: %s", strerrno());
+ goto free_out;
+ }
+ } else
+ m->msg_fp = NULL;
if (strlen(o->coremask) > 0) {
if (expand_coremask(o->coremask, &m->cores, &m->nr_cores) < 0)