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
f1b64aa7
Commit
f1b64aa7
authored
Nov 02, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
os, syscall: update for error
R=adg CC=golang-dev
https://golang.org/cl/5333052
parent
44526cdb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
13 deletions
+10
-13
env_windows.go
src/pkg/os/env_windows.go
+2
-1
exec_windows.go
src/pkg/os/exec_windows.go
+3
-2
dll_windows.go
src/pkg/syscall/dll_windows.go
+5
-10
No files found.
src/pkg/os/env_windows.go
View file @
f1b64aa7
...
@@ -7,13 +7,14 @@
...
@@ -7,13 +7,14 @@
package
os
package
os
import
(
import
(
"errors"
"syscall"
"syscall"
"utf16"
"utf16"
"unsafe"
"unsafe"
)
)
// ENOENV is the error indicating that an environment variable does not exist.
// ENOENV is the error indicating that an environment variable does not exist.
var
ENOENV
=
NewError
(
"no such environment variable"
)
var
ENOENV
=
errors
.
New
(
"no such environment variable"
)
// Getenverror retrieves the value of the environment variable named by the key.
// Getenverror retrieves the value of the environment variable named by the key.
// It returns the value and an error, if any.
// It returns the value and an error, if any.
...
...
src/pkg/os/exec_windows.go
View file @
f1b64aa7
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
package
os
package
os
import
(
import
(
"errors"
"runtime"
"runtime"
"syscall"
"syscall"
)
)
...
@@ -17,7 +18,7 @@ func (p *Process) Wait(options int) (w *Waitmsg, err error) {
...
@@ -17,7 +18,7 @@ func (p *Process) Wait(options int) (w *Waitmsg, err error) {
case
syscall
.
WAIT_FAILED
:
case
syscall
.
WAIT_FAILED
:
return
nil
,
NewSyscallError
(
"WaitForSingleObject"
,
e
)
return
nil
,
NewSyscallError
(
"WaitForSingleObject"
,
e
)
default
:
default
:
return
nil
,
NewError
(
"os: unexpected result from WaitForSingleObject"
)
return
nil
,
errors
.
New
(
"os: unexpected result from WaitForSingleObject"
)
}
}
var
ec
uint32
var
ec
uint32
e
=
syscall
.
GetExitCodeProcess
(
syscall
.
Handle
(
p
.
handle
),
&
ec
)
e
=
syscall
.
GetExitCodeProcess
(
syscall
.
Handle
(
p
.
handle
),
&
ec
)
...
@@ -31,7 +32,7 @@ func (p *Process) Wait(options int) (w *Waitmsg, err error) {
...
@@ -31,7 +32,7 @@ func (p *Process) Wait(options int) (w *Waitmsg, err error) {
// Signal sends a signal to the Process.
// Signal sends a signal to the Process.
func
(
p
*
Process
)
Signal
(
sig
Signal
)
error
{
func
(
p
*
Process
)
Signal
(
sig
Signal
)
error
{
if
p
.
done
{
if
p
.
done
{
return
NewError
(
"os: process already finished"
)
return
errors
.
New
(
"os: process already finished"
)
}
}
switch
sig
.
(
UnixSignal
)
{
switch
sig
.
(
UnixSignal
)
{
case
SIGKILL
:
case
SIGKILL
:
...
...
src/pkg/syscall/dll_windows.go
View file @
f1b64aa7
...
@@ -8,15 +8,10 @@ import (
...
@@ -8,15 +8,10 @@ import (
"sync"
"sync"
)
)
// An Error can represent any printable error condition.
type
Error
interface
{
String
()
string
}
// Errno is the Windows error number.
// Errno is the Windows error number.
type
Errno
uint64
type
Errno
uint64
func
(
e
Errno
)
String
()
string
{
return
Errstr
(
int
(
e
))
}
func
(
e
Errno
)
Error
()
string
{
return
Errstr
(
int
(
e
))
}
// DLLError describes reasons for DLL load failures.
// DLLError describes reasons for DLL load failures.
type
DLLError
struct
{
type
DLLError
struct
{
...
@@ -42,7 +37,7 @@ type DLL struct {
...
@@ -42,7 +37,7 @@ type DLL struct {
}
}
// LoadDLL loads DLL file into memory.
// LoadDLL loads DLL file into memory.
func
LoadDLL
(
name
string
)
(
dll
*
DLL
,
err
E
rror
)
{
func
LoadDLL
(
name
string
)
(
dll
*
DLL
,
err
e
rror
)
{
h
,
e
:=
loadlibrary
(
StringToUTF16Ptr
(
name
))
h
,
e
:=
loadlibrary
(
StringToUTF16Ptr
(
name
))
if
e
!=
0
{
if
e
!=
0
{
return
nil
,
&
DLLError
{
return
nil
,
&
DLLError
{
...
@@ -69,7 +64,7 @@ func MustLoadDLL(name string) *DLL {
...
@@ -69,7 +64,7 @@ func MustLoadDLL(name string) *DLL {
// FindProc searches DLL d for procedure named name and returns *Proc
// FindProc searches DLL d for procedure named name and returns *Proc
// if found. It returns an error if search fails.
// if found. It returns an error if search fails.
func
(
d
*
DLL
)
FindProc
(
name
string
)
(
proc
*
Proc
,
err
E
rror
)
{
func
(
d
*
DLL
)
FindProc
(
name
string
)
(
proc
*
Proc
,
err
e
rror
)
{
a
,
e
:=
getprocaddress
(
uintptr
(
d
.
Handle
),
StringBytePtr
(
name
))
a
,
e
:=
getprocaddress
(
uintptr
(
d
.
Handle
),
StringBytePtr
(
name
))
if
e
!=
0
{
if
e
!=
0
{
return
nil
,
&
DLLError
{
return
nil
,
&
DLLError
{
...
@@ -160,7 +155,7 @@ type LazyDLL struct {
...
@@ -160,7 +155,7 @@ type LazyDLL struct {
// Load loads DLL file d.Name into memory. It returns an error if fails.
// Load loads DLL file d.Name into memory. It returns an error if fails.
// Load will not try to load DLL, if it is already loaded into memory.
// Load will not try to load DLL, if it is already loaded into memory.
func
(
d
*
LazyDLL
)
Load
()
E
rror
{
func
(
d
*
LazyDLL
)
Load
()
e
rror
{
if
d
.
dll
==
nil
{
if
d
.
dll
==
nil
{
d
.
mu
.
Lock
()
d
.
mu
.
Lock
()
defer
d
.
mu
.
Unlock
()
defer
d
.
mu
.
Unlock
()
...
@@ -211,7 +206,7 @@ type LazyProc struct {
...
@@ -211,7 +206,7 @@ type LazyProc struct {
// Find searches DLL for procedure named p.Name. It returns
// Find searches DLL for procedure named p.Name. It returns
// an error if search fails. Find will not search procedure,
// an error if search fails. Find will not search procedure,
// if it is already found and loaded into memory.
// if it is already found and loaded into memory.
func
(
p
*
LazyProc
)
Find
()
E
rror
{
func
(
p
*
LazyProc
)
Find
()
e
rror
{
if
p
.
proc
==
nil
{
if
p
.
proc
==
nil
{
p
.
mu
.
Lock
()
p
.
mu
.
Lock
()
defer
p
.
mu
.
Unlock
()
defer
p
.
mu
.
Unlock
()
...
...
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