Setpgid, PTY & "operation not permitted"

It couldn’t be something so daft as forgetting to chmod +x pty-test.sh ? :smile:

Oh hey!

root@ubuntu:~# chmod +x pty-test.sh
root@ubuntu:~# go run pty-test.go
panic: fork/exec /root/pty-test.sh: operation not permitted

goroutine 1 [running]:
main.main()
	/root/pty-test.go:24 +0x229
exit status 2

This is a super fresh DO instance I just provisioned to run this test (I actually made a Ubuntu 15 box)

root@ubuntu:~# setenforce 0
The program 'setenforce' is currently not installed. You can install it by typing:
apt-get install selinux-utils

Even if it isn’t a bash file:

root@ubuntu:~# go run pty-test.go
panic: fork/exec /bin/ls: operation not permitted

goroutine 1 [running]:
main.main()
	/root/pty-test.go:27 +0x18a
exit status 2

@dfc I just had a thought. This code snipped used to work for me, until I updated to the latest kr/pty where they fixed this bug: https://github.com/kr/pty/commit/f7ee69f31298ecbe5d2b349c711e2547a617d398

Is there a chance you’ve got the older version of kr/pty installed with the bug still present? (Which causes the call to Setpgid to be ignored)

1 Like

I’m out of ideas. You may resume shaving your yak :stuck_out_tongue:

No idea. I had a version of KR/Pty on my machine so it compiled and I didn’t give it a second thought.

Confirmed, with the latest kr/pty, I now see the same bug/fix as you

lucky(~/src) % ./pty-test
panic: fork/exec /home/dfc/src/pty-test.sh: operation not permitted

goroutine 1 [running]:
main.main()
        /home/dfc/src/pty-test.go:24 +0x22a

Let’s chalk this one up to Go’s lack of dependency management.

2 Likes

You know what’s funny? I literally stumbled across this just now: https://www.youtube.com/watch?v=c3dW80eO88I

2 Likes

So, Setpgid is the reason?

Yup, if you remove the call to Setpgid, then it works as expected across all platforms. I’ve confirmed on a few other machines now (you need latest kr/pty and it’s broken there as well.

Is there something fundamental about this that I’m doing wrong maybe?

at this stage it looks like a bug to me. no harm in opening a bug on std lib.

I’ve never done that before! Is there a “hot to submit a bug” guide somewhere?

You can file the issue here to start with:

1 Like

For those that are interested, kr found came up with an answer: https://github.com/kr/pty/issues/35#issuecomment-147947212

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.