Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
80d2eac1
Commit
80d2eac1
authored
Mar 01, 2013
by
Rémy Oudompheng
Committed by
Russ Cox
Mar 01, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/cgo: don't reimplement os/exec in util.go.
R=golang-dev, rsc CC=golang-dev
https://golang.org/cl/7450049
parent
e02168f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
43 deletions
+10
-43
src/cmd/cgo/util.go
src/cmd/cgo/util.go
+10
-43
No files found.
src/cmd/cgo/util.go
View file @
80d2eac1
...
@@ -5,9 +5,9 @@
...
@@ -5,9 +5,9 @@
package
main
package
main
import
(
import
(
"bytes"
"fmt"
"fmt"
"go/token"
"go/token"
"io/ioutil"
"os"
"os"
"os/exec"
"os/exec"
)
)
...
@@ -16,50 +16,17 @@ import (
...
@@ -16,50 +16,17 @@ import (
// It returns the output to standard output and standard error.
// It returns the output to standard output and standard error.
// ok indicates whether the command exited successfully.
// ok indicates whether the command exited successfully.
func
run
(
stdin
[]
byte
,
argv
[]
string
)
(
stdout
,
stderr
[]
byte
,
ok
bool
)
{
func
run
(
stdin
[]
byte
,
argv
[]
string
)
(
stdout
,
stderr
[]
byte
,
ok
bool
)
{
cmd
,
err
:=
exec
.
LookPath
(
argv
[
0
])
p
:=
exec
.
Command
(
argv
[
0
],
argv
[
1
:
]
...
)
if
err
!=
nil
{
p
.
Stdin
=
bytes
.
NewReader
(
stdin
)
fatalf
(
"exec %s: %s"
,
argv
[
0
],
err
)
var
bout
,
berr
bytes
.
Buffer
}
p
.
Stdout
=
&
bout
r0
,
w0
,
err
:=
os
.
Pipe
()
p
.
Stderr
=
&
berr
if
err
!=
nil
{
err
:=
p
.
Run
()
fatalf
(
"%s"
,
err
)
if
_
,
ok
:=
err
.
(
*
exec
.
ExitError
);
err
!=
nil
&&
!
ok
{
}
r1
,
w1
,
err
:=
os
.
Pipe
()
if
err
!=
nil
{
fatalf
(
"%s"
,
err
)
}
r2
,
w2
,
err
:=
os
.
Pipe
()
if
err
!=
nil
{
fatalf
(
"%s"
,
err
)
}
p
,
err
:=
os
.
StartProcess
(
cmd
,
argv
,
&
os
.
ProcAttr
{
Files
:
[]
*
os
.
File
{
r0
,
w1
,
w2
}})
if
err
!=
nil
{
fatalf
(
"%s"
,
err
)
}
r0
.
Close
()
w1
.
Close
()
w2
.
Close
()
c
:=
make
(
chan
bool
)
go
func
()
{
w0
.
Write
(
stdin
)
w0
.
Close
()
c
<-
true
}()
go
func
()
{
stdout
,
_
=
ioutil
.
ReadAll
(
r1
)
r1
.
Close
()
c
<-
true
}()
stderr
,
_
=
ioutil
.
ReadAll
(
r2
)
r2
.
Close
()
<-
c
<-
c
state
,
err
:=
p
.
Wait
()
if
err
!=
nil
{
fatalf
(
"%s"
,
err
)
fatalf
(
"%s"
,
err
)
}
}
ok
=
state
.
Success
()
ok
=
p
.
ProcessState
.
Success
()
stdout
,
stderr
=
bout
.
Bytes
(),
berr
.
Bytes
()
return
return
}
}
...
...
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