Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
72f37e3d
Commit
72f37e3d
authored
Nov 27, 2023
by
Artur Wojcik
Browse files
fix broken pipe
parent
b9eb03e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
18 deletions
+10
-18
src/process.cpp
src/process.cpp
+10
-18
No files found.
src/process.cpp
View file @
72f37e3d
...
...
@@ -162,19 +162,14 @@ class pipe
return
result
;
}
std
::
optional
<
std
::
pair
<
bool
,
DWORD
>
>
read
(
LPVOID
buffer
,
DWORD
length
)
const
std
::
pair
<
bool
,
DWORD
>
read
(
LPVOID
buffer
,
DWORD
length
)
const
{
DWORD
bytes_read
;
if
(
ReadFile
(
m_read
,
buffer
,
length
,
&
bytes_read
,
nullptr
)
==
FALSE
)
if
(
ReadFile
(
m_read
,
buffer
,
length
,
&
bytes_read
,
nullptr
)
==
FALSE
and
GetLastError
()
==
ERROR_MORE_DATA
)
{
DWORD
error
{
GetLastError
()};
if
(
error
!=
ERROR_MORE_DATA
)
{
return
std
::
nullopt
;
}
return
{{
true
,
bytes_read
}};
return
{
true
,
bytes_read
};
}
return
{
{
false
,
bytes_read
}
}
;
return
{
false
,
bytes_read
};
}
HANDLE
get_read_handle
()
const
{
return
m_read
;
}
...
...
@@ -277,15 +272,12 @@ int exec(const std::pair<std::string, std::string>& cmd)
:
exec
(
cmd
,
[
&
](
const
pipe
<
direction
::
input
>&
,
const
pipe
<
direction
::
output
>&
out
)
{
for
(;;)
{
if
(
auto
result
=
out
.
read
(
buffer
,
MIGRAPHX_PROCESS_BUFSIZE
))
{
auto
&
[
more_data
,
bytes_read
]
=
*
result
;
if
(
not
more_data
or
bytes_read
==
0
)
break
;
DWORD
written
;
if
(
WriteFile
(
std_out
,
buffer
,
bytes_read
,
&
written
,
nullptr
)
==
FALSE
)
break
;
}
auto
[
more_data
,
bytes_read
]
=
out
.
read
(
buffer
,
MIGRAPHX_PROCESS_BUFSIZE
);
if
(
not
more_data
or
bytes_read
==
0
)
break
;
DWORD
written
;
if
(
WriteFile
(
std_out
,
buffer
,
bytes_read
,
&
written
,
nullptr
)
==
FALSE
)
break
;
}
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment