fix piprocess set workdir
This commit is contained in:
@@ -215,10 +215,10 @@ PRIVATE_DEFINITION_START(PIProcess)
|
|||||||
PeekNamedPipe(pipes[pipe_type][PipeRead], nullptr, 0, nullptr, &available, nullptr);
|
PeekNamedPipe(pipes[pipe_type][PipeRead], nullptr, 0, nullptr, &available, nullptr);
|
||||||
if (available > 0) {
|
if (available > 0) {
|
||||||
BOOL ok = ReadFile(pipes[pipe_type][PipeRead],
|
BOOL ok = ReadFile(pipes[pipe_type][PipeRead],
|
||||||
read_buffer.data(offset),
|
read_buffer.data(offset),
|
||||||
piMini(available, read_buffer.size() - offset),
|
piMini(available, read_buffer.size() - offset),
|
||||||
&bytes_read,
|
&bytes_read,
|
||||||
nullptr);
|
nullptr);
|
||||||
if (!ok) bytes_read = 0;
|
if (!ok) bytes_read = 0;
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
@@ -293,10 +293,10 @@ void PIProcess::startProc(bool detached) {
|
|||||||
si.dwFlags |= STARTF_USESTDHANDLES;
|
si.dwFlags |= STARTF_USESTDHANDLES;
|
||||||
const auto cmd = convertWindowsCmd(args);
|
const auto cmd = convertWindowsCmd(args);
|
||||||
if (CreateProcessA(0, // No module name (use command line)
|
if (CreateProcessA(0, // No module name (use command line)
|
||||||
(LPSTR)cmd.data(), // Command line
|
(LPSTR)cmd.data(), // Command line
|
||||||
0, // Process handle not inheritable
|
0, // Process handle not inheritable
|
||||||
0, // Thread handle not inheritable
|
0, // Thread handle not inheritable
|
||||||
true, // Set handle inheritance to FALSE
|
true, // Set handle inheritance to FALSE
|
||||||
detached ? DETACHED_PROCESS /*CREATE_NEW_CONSOLE*/ : 0, // Creation flags
|
detached ? DETACHED_PROCESS /*CREATE_NEW_CONSOLE*/ : 0, // Creation flags
|
||||||
0, // Use environment
|
0, // Use environment
|
||||||
wd.isEmpty() ? 0 : wd.data(), // Use working directory
|
wd.isEmpty() ? 0 : wd.data(), // Use working directory
|
||||||
@@ -322,7 +322,7 @@ void PIProcess::startProc(bool detached) {
|
|||||||
if (!detached) PRIVATE->pid = pid_;
|
if (!detached) PRIVATE->pid = pid_;
|
||||||
if (pid_ == 0) {
|
if (pid_ == 0) {
|
||||||
if (!wd.isEmpty()) {
|
if (!wd.isEmpty()) {
|
||||||
if (!chdir(wd.data())) piCoutObj << "Error while set working directory";
|
if (chdir(wd.data()) != 0) piCoutObj << "Error while set working directory";
|
||||||
}
|
}
|
||||||
PRIVATE->closePipe(StdIn, PipeWrite);
|
PRIVATE->closePipe(StdIn, PipeWrite);
|
||||||
PRIVATE->closePipe(StdOut, PipeRead);
|
PRIVATE->closePipe(StdOut, PipeRead);
|
||||||
|
|||||||
Reference in New Issue
Block a user