Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
e50611d2
Commit
e50611d2
authored
Sep 07, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
os, exec: rename argv0 to name
R=r, gri1 CC=golang-dev
https://golang.org/cl/2119044
parent
1cec72cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
exec.go
src/pkg/exec/exec.go
+3
-3
exec.go
src/pkg/os/exec.go
+10
-10
No files found.
src/pkg/exec/exec.go
View file @
e50611d2
...
...
@@ -63,7 +63,7 @@ func modeToFiles(mode, fd int) (*os.File, *os.File, os.Error) {
return
nil
,
nil
,
os
.
EINVAL
}
// Run starts the
binary prog
running with
// Run starts the
named binary
running with
// arguments argv and environment envv.
// It returns a pointer to a new Cmd representing
// the command or an error.
...
...
@@ -78,7 +78,7 @@ func modeToFiles(mode, fd int) (*os.File, *os.File, os.Error) {
// If a parameter is Pipe, then the corresponding field (Stdin, Stdout, Stderr)
// of the returned Cmd is the other end of the pipe.
// Otherwise the field in Cmd is nil.
func
Run
(
argv0
string
,
argv
,
envv
[]
string
,
dir
string
,
stdin
,
stdout
,
stderr
int
)
(
p
*
Cmd
,
err
os
.
Error
)
{
func
Run
(
name
string
,
argv
,
envv
[]
string
,
dir
string
,
stdin
,
stdout
,
stderr
int
)
(
p
*
Cmd
,
err
os
.
Error
)
{
p
=
new
(
Cmd
)
var
fd
[
3
]
*
os
.
File
...
...
@@ -95,7 +95,7 @@ func Run(argv0 string, argv, envv []string, dir string, stdin, stdout, stderr in
}
// Run command.
p
.
Pid
,
err
=
os
.
ForkExec
(
argv0
,
argv
,
envv
,
dir
,
fd
[
0
:
])
p
.
Pid
,
err
=
os
.
ForkExec
(
name
,
argv
,
envv
,
dir
,
fd
[
0
:
])
if
err
!=
nil
{
goto
Error
}
...
...
src/pkg/os/exec.go
View file @
e50611d2
...
...
@@ -8,14 +8,14 @@ import (
"syscall"
)
// ForkExec forks the current process and invokes Exec with the
file
, arguments,
// and environment specified by
argv0
, argv, and envv. It returns the process
// ForkExec forks the current process and invokes Exec with the
program
, arguments,
// and environment specified by
name
, argv, and envv. It returns the process
// id of the forked process and an Error, if any. The fd array specifies the
// file descriptors to be set up in the new process: fd[0] will be Unix file
// descriptor 0 (standard input), fd[1] descriptor 1, and so on. A nil entry
// will cause the child to have no open file descriptor with that index.
// If dir is not empty, the child chdirs into the directory before execing the program.
func
ForkExec
(
argv0
string
,
argv
[]
string
,
envv
[]
string
,
dir
string
,
fd
[]
*
File
)
(
pid
int
,
err
Error
)
{
func
ForkExec
(
name
string
,
argv
[]
string
,
envv
[]
string
,
dir
string
,
fd
[]
*
File
)
(
pid
int
,
err
Error
)
{
if
envv
==
nil
{
envv
=
Environ
()
}
...
...
@@ -29,24 +29,24 @@ func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*File
}
}
p
,
e
:=
syscall
.
ForkExec
(
argv0
,
argv
,
envv
,
dir
,
intfd
)
p
,
e
:=
syscall
.
ForkExec
(
name
,
argv
,
envv
,
dir
,
intfd
)
if
e
!=
0
{
return
0
,
&
PathError
{
"fork/exec"
,
argv0
,
Errno
(
e
)}
return
0
,
&
PathError
{
"fork/exec"
,
name
,
Errno
(
e
)}
}
return
p
,
nil
}
// Exec replaces the current process with an execution of the
program
// named b
y argv0
, with arguments argv and environment envv.
// Exec replaces the current process with an execution of the
// named b
inary
, with arguments argv and environment envv.
// If successful, Exec never returns. If it fails, it returns an Error.
// ForkExec is almost always a better way to execute a program.
func
Exec
(
argv0
string
,
argv
[]
string
,
envv
[]
string
)
Error
{
func
Exec
(
name
string
,
argv
[]
string
,
envv
[]
string
)
Error
{
if
envv
==
nil
{
envv
=
Environ
()
}
e
:=
syscall
.
Exec
(
argv0
,
argv
,
envv
)
e
:=
syscall
.
Exec
(
name
,
argv
,
envv
)
if
e
!=
0
{
return
&
PathError
{
"exec"
,
argv0
,
Errno
(
e
)}
return
&
PathError
{
"exec"
,
name
,
Errno
(
e
)}
}
return
nil
}
...
...
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