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
29e4775c
Commit
29e4775c
authored
Jun 07, 2011
by
Brad Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exec: export the underlying *os.Process in Cmd
R=rsc CC=golang-dev
https://golang.org/cl/4579044
parent
a8fd3741
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
src/pkg/exec/exec.go
src/pkg/exec/exec.go
+11
-9
No files found.
src/pkg/exec/exec.go
View file @
29e4775c
...
...
@@ -62,9 +62,11 @@ type Cmd struct {
Stdout
io
.
Writer
Stderr
io
.
Writer
// Process is the underlying process, once started.
Process
*
os
.
Process
err
os
.
Error
// last error (from LookPath, stdin, stdout, stderr)
process
*
os
.
Process
finished
bool
// when Wait was called
finished
bool
// when Wait was called
childFiles
[]
*
os
.
File
closeAfterStart
[]
io
.
Closer
closeAfterWait
[]
io
.
Closer
...
...
@@ -205,7 +207,7 @@ func (c *Cmd) Start() os.Error {
if
c
.
err
!=
nil
{
return
c
.
err
}
if
c
.
p
rocess
!=
nil
{
if
c
.
P
rocess
!=
nil
{
return
os
.
NewError
(
"exec: already started"
)
}
...
...
@@ -219,7 +221,7 @@ func (c *Cmd) Start() os.Error {
}
var
err
os
.
Error
c
.
p
rocess
,
err
=
os
.
StartProcess
(
c
.
Path
,
c
.
argv
(),
&
os
.
ProcAttr
{
c
.
P
rocess
,
err
=
os
.
StartProcess
(
c
.
Path
,
c
.
argv
(),
&
os
.
ProcAttr
{
Dir
:
c
.
Dir
,
Files
:
c
.
childFiles
,
Env
:
c
.
envv
(),
...
...
@@ -253,14 +255,14 @@ func (c *Cmd) Start() os.Error {
// error is of type *os.Waitmsg. Other error types may be
// returned for I/O problems.
func
(
c
*
Cmd
)
Wait
()
os
.
Error
{
if
c
.
p
rocess
==
nil
{
if
c
.
P
rocess
==
nil
{
return
os
.
NewError
(
"exec: not started"
)
}
if
c
.
finished
{
return
os
.
NewError
(
"exec: Wait was already called"
)
}
c
.
finished
=
true
msg
,
err
:=
c
.
p
rocess
.
Wait
(
0
)
msg
,
err
:=
c
.
P
rocess
.
Wait
(
0
)
var
copyError
os
.
Error
for
_
=
range
c
.
goroutine
{
...
...
@@ -315,7 +317,7 @@ func (c *Cmd) StdinPipe() (io.WriteCloser, os.Error) {
if
c
.
Stdin
!=
nil
{
return
nil
,
os
.
NewError
(
"exec: Stdin already set"
)
}
if
c
.
p
rocess
!=
nil
{
if
c
.
P
rocess
!=
nil
{
return
nil
,
os
.
NewError
(
"exec: StdinPipe after process started"
)
}
pr
,
pw
,
err
:=
os
.
Pipe
()
...
...
@@ -334,7 +336,7 @@ func (c *Cmd) StdoutPipe() (io.Reader, os.Error) {
if
c
.
Stdout
!=
nil
{
return
nil
,
os
.
NewError
(
"exec: Stdout already set"
)
}
if
c
.
p
rocess
!=
nil
{
if
c
.
P
rocess
!=
nil
{
return
nil
,
os
.
NewError
(
"exec: StdoutPipe after process started"
)
}
pr
,
pw
,
err
:=
os
.
Pipe
()
...
...
@@ -353,7 +355,7 @@ func (c *Cmd) StderrPipe() (io.Reader, os.Error) {
if
c
.
Stderr
!=
nil
{
return
nil
,
os
.
NewError
(
"exec: Stderr already set"
)
}
if
c
.
p
rocess
!=
nil
{
if
c
.
P
rocess
!=
nil
{
return
nil
,
os
.
NewError
(
"exec: StderrPipe after process started"
)
}
pr
,
pw
,
err
:=
os
.
Pipe
()
...
...
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