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

x/sys/unix: add missing values from syscall pkg to enable complete migration #19697

Open
laboger opened this issue Mar 24, 2017 · 9 comments

Comments

@laboger
Copy link
Contributor

commented Mar 24, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go tip

What operating system and processor architecture are you using (go env)?

Ubuntu 16.04 and Fedora22, Red Hat 7.x on ppc64le & ppc64

What did you do?

Trying to migrate Go code from syscall to sys/unix as described in the golang syscall package documentation https://golang.org/pkg/syscall/. This was the suggested solution for issue #19560. While it is possible to fix just the case that is described in this issue, that is not a complete solution. We want to avoid hitting another issue because of using syscall, so we'd like to migrate use of syscall to sys/unix. Also having a mixture of references to syscall and sys/unix is confusing since then it is not clear when to use which one.

Issues with migrating from syscall to sys/unix:

  1. syscall.Signal and syscall.Errno need to have a type defined within sys/unix so user code doesn't need to use these to convert signals and errnos to the appropriate integer type for the platform.

I was going to try a change for this based on a suggestion by Ian, but I'm not able to get the generator scripts in sys/unix to work. I get these errors:

GOOS=linux GOARCH=ppc64le ./mkall.sh
could not determine kind of name for C.TIOCGETC
could not determine kind of name for C.TIOCGETP
could not determine kind of name for C.TIOCGLTC
could not determine kind of name for C.TIOCSETC
could not determine kind of name for C.TIOCSETN
could not determine kind of name for C.TIOCSETP
could not determine kind of name for C.TIOCSLTC

This happened on Fedora22 and Ubuntu 16.04. If I could get some direction on what this might be that would help.

  1. The structure SysProcAttr is defined in syscall but not in sys/unix. It is used in the os package, so I don't think it should be moved to sys/unix. Seems like it needs an equivalent declaration in os.

@gopherbot gopherbot added this to the Unreleased milestone Mar 24, 2017

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Mar 24, 2017

I think that syscall.SysProcAttr is a different issue to be dealt with differently. In fact I don't see any reason to migrate that to x/sys/unix. It's fine where it is.

@clnperez

This comment has been minimized.

Copy link

commented Mar 28, 2017

Hm. Wouldn't that mean still using syscall then? Or is there an alternative for users that's outside of syscall for syscall.SysProcAttr?

@bradfitz

This comment has been minimized.

Copy link
Member

commented Mar 28, 2017

@clnperez, yes, still using syscall. There's no alternative. It's part of the API: https://golang.org/pkg/os/exec/#Cmd.SysProcAttr

@laboger

This comment has been minimized.

Copy link
Contributor Author

commented Mar 28, 2017

Then those things that can't be migrated from syscall to sys/unix should be documented so it is clear. Right now the syscall package documentation just says to migrate from syscall to sys/unix. Maybe that paragraph just needs a statement to identify the exceptions.

@bradfitz

This comment has been minimized.

Copy link
Member

commented Mar 28, 2017

That is the only case:

$ cd $GOROOT/api
$ git grep syscall | grep -v ":pkg syscall" | grep txt:pkg
go1.txt:pkg os, type ProcAttr struct, Sys *syscall.SysProcAttr
go1.txt:pkg os/exec, type Cmd struct, SysProcAttr *syscall.SysProcAttr

If you want to add something minimal to the pkg syscall docs, feel free to send a CL.

@laboger

This comment has been minimized.

Copy link
Contributor Author

commented Mar 29, 2017

Apparently at this point in time the generator scripts in the syscall pkg and x/sys/unix are not in sync with the z files they generate. I could make the necessary changes to add definitions of Signal and Errno in sys/unix but don't know how to correctly generate all the right files without a lot of extra unrelated changes or lots of manual changes.

Will changing the comments in syscall/syscall.go update the pkg syscall docs?

@bradfitz

This comment has been minimized.

Copy link
Member

commented Mar 29, 2017

@bradfitz

This comment has been minimized.

Copy link
Member

commented Mar 29, 2017

Will changing the comments in syscall/syscall.go update the pkg syscall docs?

Yes. You can send a CL for that part at least.

@gopherbot

This comment has been minimized.

Copy link

commented Nov 30, 2017

Change https://golang.org/cl/80955 mentions this issue: unix: add netlink functions on Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.