only initialize the data late

master
Daniel Kolesa 2017-05-08 20:38:46 +02:00
parent 5d16d8fd87
commit 045a280c56
1 changed files with 2 additions and 3 deletions

View File

@ -201,9 +201,6 @@ OSTD_EXPORT void subprocess::open_impl(
}
argp[args.size()] = nullptr;
p_current = ::new (reinterpret_cast<void *>(&p_data)) data{};
data *pd = static_cast<data *>(p_current);
/* fd_errno used to detect if exec failed */
pipe fd_errno, fd_stdin, fd_stdout, fd_stderr;
@ -270,6 +267,8 @@ OSTD_EXPORT void subprocess::open_impl(
fd_stderr.close(true);
fd_stderr.fdopen(err, false);
}
p_current = ::new (reinterpret_cast<void *>(&p_data)) data{};
data *pd = static_cast<data *>(p_current);
pd->pid = int(cpid);
pd->errno_fd = std::exchange(fd_errno[1], -1);
}