diff options
author | Ryo Nakamura <upa@haeena.net> | 2023-03-15 00:39:56 +0900 |
---|---|---|
committer | Ryo Nakamura <upa@haeena.net> | 2023-03-15 00:39:56 +0900 |
commit | 4e80b05da763f6ab10e2885a164856cc7afd8fb9 (patch) | |
tree | e39e9442eb0f5a473c95f7cdc3d46d1a5a47b0d0 /src | |
parent | 98eca409af5380f9dd8ec31e0a2f7fef7d2820bf (diff) |
do not fdopen(msg_fd) if msg_fd < 0
Diffstat (limited to 'src')
-rw-r--r-- | src/mscp.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -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) |