forked from OctaForge/libostd
only initialize the data late
This commit is contained in:
parent
5d16d8fd87
commit
045a280c56
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue