Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error handling on darwin #47

Merged
merged 1 commit into from
Oct 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion sigar_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,16 @@ func kern_procargs(pid int,
if exe != nil {
exe(string(chop(path)))
}
if err != nil {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this error check be even before the exe part?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, would be better, I'll create another PR.

return fmt.Errorf("Error reading the argv[0]: %v", err)
}

// skip trailing \0's
for {
c, _ := bbuf.ReadByte()
c, err := bbuf.ReadByte()
if err != nil {
return fmt.Errorf("Error skipping nils: %v", err)
}
if c != 0 {
bbuf.UnreadByte()
break // start of argv[0]
Expand All @@ -379,6 +385,9 @@ func kern_procargs(pid int,
if err == io.EOF {
break
}
if err != nil {
return fmt.Errorf("Error reading args: %v", err)
}
if argv != nil {
argv(string(chop(arg)))
}
Expand All @@ -395,6 +404,9 @@ func kern_procargs(pid int,
if err == io.EOF || line[0] == 0 {
break
}
if err != nil {
return fmt.Errorf("Error reading args: %v", err)
}
pair := bytes.SplitN(chop(line), delim, 2)
env(string(pair[0]), string(pair[1]))
}
Expand Down